I modified the code to accept an XML string instead of opening a file.
Public Message As String
Public Sub LoadXML()
Dim d As New DataSet() 'Dim local dataset object for this method
Try
Dim XmlDataDocument As New XmlDataDocument
XmlDataDocument.DataSet.ReadXml(New IO.StringReader(Message))
d = XmlDataDocument.DataSet.Copy
dg1.DataSource = d ' bind datagrid control to the local dataset object
Catch exp As Exception ' catch any exceptions that may get thrown and display in messagebox
MessageBox.Show(exp.Message.ToString, "Exception was caught", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
ds = d.Copy 'copy local dataset object up to global dataset for persistance
dg1.DataSource = ds 'reset datagrid datasource property to global dataset object
dg1.Refresh() 'refresh datagrid
dg1.Collapse(-1) 'collapse datagrid to get back to root node
d.Dispose() ' dispose of local dataset object
End Sub
Enter your message below
Sign in or Join us (it's free).