
{filelink=16389}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml;
public class DataGridVersXML : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnEngDtGrid;
private System.Windows.Forms.DataGrid MonDataGrid;
private System.ComponentModel.Container components = null;
public DataGridVersXML() {
InitializeComponent();
charger();
}
void charger()
{
DataSet ds = new DataSet();
ds.ReadXml("Operations.xml", XmlReadMode.InferSchema);
MonDataGrid.SetDataBinding(ds, "Clients");
}
private void InitializeComponent() {
this.btnEngDtGrid = new System.Windows.Forms.Button();
this.MonDataGrid = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.MonDataGrid)).BeginInit();
this.SuspendLayout();
//
// btnEngDtGrid
//
this.btnEngDtGrid.Location = new System.Drawing.Point(111, 206);
this.btnEngDtGrid.Name = "btnEngDtGrid";
this.btnEngDtGrid.Size = new System.Drawing.Size(307, 23);
this.btnEngDtGrid.TabIndex = 1;
this.btnEngDtGrid.Text = "Enregistrer le DataGrid dans un document XML";
this.btnEngDtGrid.Click += new System.EventHandler(this.btnEngDtGrid_Click_1);
//
// MonDataGrid
//
this.MonDataGrid.DataMember = "";
this.MonDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.MonDataGrid.Location = new System.Drawing.Point(1, 0);
this.MonDataGrid.Name = "MonDataGrid";
this.MonDataGrid.Size = new System.Drawing.Size(581, 200);
this.MonDataGrid.TabIndex = 3;
//
// DataGridVersXML
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(579, 272);
this.Controls.Add(this.MonDataGrid);
this.Controls.Add(this.btnEngDtGrid);
this.Name = "DataGridVersXML";
this.Text = "Exporter DataGrid Vers Document XML";
((System.ComponentModel.ISupportInitialize)(this.MonDataGrid)).EndInit();
this.ResumeLayout(false);
}
static void Main()
{
Application.Run(new DataGridVersXML());
}
private void btnEngDtGrid_Click_1(object sender, EventArgs e)
{
DataSet ds = (DataSet) MonDataGrid.DataSource;
ds.WriteXml("DataGrid.xml",XmlWriteMode.IgnoreSchema);
}
}
/*
//Fichier XML: Operation.xml
CCLiege
Genital
Frederic Moulard
D.G Commercial
15 Rue X
Paris
2025
France
20-30-14-30-65
20-30-14-30-66
CCVerge
XMey
Herve Banste
PDG
30, rue des Galliers
Marseille
13008
France
32-15-22-16-63
32-15-22-16-64
CCDerge
Fourgon
Samuel Etienne
D.G Commercial
Cener Str. 213
Berlin
12209
Allemagne
044-2014587
044-2014588
*/