vb.net datagridview中保存到xml

前端之家收集整理的这篇文章主要介绍了vb.net datagridview中保存到xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

’写:   
 Private Sub Button4_Click(sender As System.Object,e As System.EventArgs) Handles Button4.Click   
        Dim ds As New DataSet
        ds = DataGridView1.DataSource
        ds.WriteXml("test2.xml")
    End Sub
‘读取
    Private Sub Button5_Click(sender As System.Object,e As System.EventArgs) Handles Button5.Click
        Dim ds As New DataSet
        ds.ReadXml("test.xml")
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = "node"
    End Sub

'xml:
<?xml version="1.0" standalone="yes"?>
<xml>
  <node id="1">
    <name>myname</name>
    <place>country</place>
  </node>
</xml>

猜你在找的VB相关文章