How to Display the Records in the DataGridView Using VB.Net and XML File
Submitted by janobe on Wednesday, August 14, 2019 - 13:31.
In this tutorial, I will teach you how to display the record in the datagridview using vb.net and xml file. This simple project will help you how to get the records from XML file and display it into the DataGridView. It also illustrates what is the method to be used when they bind to each other. Hope this tutorial will help your current problem. Let’s begin.
The complete source code is included. You can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form.
Step 2
Add a Button and DataGridView in the form. It will look like this.
Step 3
Go to the solution explorer and right-click the project name. After that, select “Add” and hit “new item”
Step 4
Choose XML File in the dialog box, then hit “add”.
Step 5
Double click the XML file and add the following codes for the list of records.- <NewDataSet>
- <person>
- <Name>Janno Palacios</Name>
- <Address>Kabankalan City</Address>
- </person>
- <person>
- <Name>Jeanniebe Palacios</Name>
- <Address>Kabankalan City</Address>
- </person>
- <person>
- <Name>Craig Palacios</Name>
- <Address>Kabankalan City</Address>
- </person>
- <person>
- <Name>Kenjie Palacios</Name>
- <Address>Kabankalan City</Address>
- </person>
- </NewDataSet>
Step 6
Go to the resources and drag the XML file.
Step 7
Double click the button and do the following codes for retrieving data in the XML File when the button is click.- Dim dsPerson As DataSet = New DataSet()
- dsPerson.ReadXml(New System.IO.StringReader(My.Resources.XMLFile1))
- DataGridView1.DataSource = dsPerson.Tables(0)
Add new comment
- 452 views