Haha! You are familiar with dataset, datagridview, and XML! I will not introduce it here. Let's go straight to the theme! The key section is provided here. Code ! For reference only
Code
// I am writing it in the loading event of the form.
Private Void Form1_load ( Object Sender, eventargs E)
{
// Instantiate a DataSet object to read data in the XML file.
Dataset Set = New Dataset ();
// Use set to read XML files
Set . Readxml ( @" E: \ xmlfile. xml " );
// Set the data source of the datagridview
Datagridview. datasource = Set . Tables [ 0 ];
}
Since the XML file can be read to the datagridview, can the data of the XML file be modified in the datagridview? The answer is yes! In fact, the Code is also very simple!
Code
1 // Button clicking event
2 Private Void Button_click ( Object Sender, eventargs E)
3 {< br> 4 // it is also called (Dataset) set writexml ()
5 set . writexml ( @ " E: \ xmlfile. XML " );
6 // the set object here is the set object instantiated above. The same object is used in the same form.
7 }
8