Datagrid|xml
Note: I mainly refer to an article on the internet called: "VB and vb.net XML Operations" article url:http://www.wrclub.net/study/listarticle.aspx?id=1459
It introduces the general process in the inside, but in my actual application process
In the article code:
Dim MYSDD as System.Xml.XmlDataDocument
MYXDD = New System.Xml.XmlDataDocument (me.dsmaster1)
Myxdd.load ("Dataonly.xml")
Setbindings (Me.dsmaster1)
Setbindings This method has never known what it is, and can not be found in MSDN, so the end is not in accordance with his article method implementation. Refer to MSDN, but this article for my help is still relatively large, although also led me to take some detours.
Here are two main events that will load XML into the DataGrid:
' If you use DS to do DataSource, you will not expand the DataGrid, with DV you can directly display the correct.
Dim ds As DataSet = New DataSet
Ds. READXML (XmlFile)
Dim TB as DataTable
Dim DV as DataView
TB = ds. Tables (0)
DV = New DataView (TB)
' DataGrid1.DataSource = DV
' DataGrid1.DataMember = ' testxmlmember '
' DataGrid1.DataMember = ' employeefname '
' Dim dxd as New XmlDataDocument
DataGrid1.SetDataBinding (DV, "")
XMLDD = New XmlDataDocument (ds)
Note the position of both the DS and XMLDD reference variables. Find MSDN to find the appropriate help. The specific is to avoid repeated binding errors.
Another event in the Save event, as long as the direct call:
Xmldd.save (XmlFile)
Can
This enables the XML to be displayed in the grid, and then saves the content in the grid to the XML file.
The beginning of everything is difficult, open a head, the next is not so difficult!
If you use. NET to manipulate XML, I think the main classes used are XmlDocument, XMLReader, XMLWriter, and their derived classes, which can be found in MSDN!
The next task is to get a node, then only need to update a node, and through the XML relational table mapping related to the correct object and so on!