VB.net reads and writes XML (2)--realizes the communication between the DataGrid and XML

Source: Internet
Author: User
Tags net xml
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!




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.