Hello, I hope someone can give me some help.
I have a datagridview (Unbound), wich calculate several numbers, and I use this following code to save 5 of the columns to a XML file.
My problem is that I would like to load this file back to my datagridview, and onlu to the same columns, without changing the rest of the datagridview.
Code used to create XML file:
Code:
I have tried with the following code but when I use this, the data from my XML file appear at the end of my datagridview (Adding 5 more columns to the end). I would like to "update" the same columns...
Code I use to Load XML file:
Code:
Anyone knows how I can load my XML file, and only update certain columns in my datagridview and not add 5 more columns to my datagridview?
Is there a way to load the XML data to my datagridview without binding the datagridview to the XML file?
I mean without the use of the:
Code:
I have a datagridview (Unbound), wich calculate several numbers, and I use this following code to save 5 of the columns to a XML file.
My problem is that I would like to load this file back to my datagridview, and onlu to the same columns, without changing the rest of the datagridview.
Code used to create XML file:
Code:
VB.NET:
Dim gridtable As DataTable = New DataTable("WaypointLeg")
Dim gridtable_collumn1 As DataColumn = New DataColumn("column1")
Dim gridtable_collumn11 As DataColumn = New DataColumn("column11")
Dim gridtable_collumn18 As DataColumn = New DataColumn("column18")
Dim gridtable_collumn19 As DataColumn = New DataColumn("column19")
Dim gridtable_collumn20 As DataColumn = New DataColumn("column20")
Dim name As String
name = IDTextBox.Text
gridtable.Columns.Add(gridtable_collumn1)
gridtable.Columns.Add(gridtable_collumn11)
gridtable.Columns.Add(gridtable_collumn18)
gridtable.Columns.Add(gridtable_collumn19)
gridtable.Columns.Add(gridtable_collumn20)
Dim gridrow As DataGridViewRow
Dim table_row As DataRow
For Each gridrow In DataGridView1.Rows
table_row = gridtable.NewRow
table_row("column1") = gridrow.Cells("column1").Value
table_row("column11") = gridrow.Cells("column11").Value
table_row("column18") = gridrow.Cells("column18").Value
table_row("column19") = gridrow.Cells("column19").Value
table_row("column20") = gridrow.Cells("column20").Value
gridtable.Rows.Add(table_row)
gridtable.WriteXml(Application.StartupPath & "\Data\" & name & ".xml")
Next gridrow
I have tried with the following code but when I use this, the data from my XML file appear at the end of my datagridview (Adding 5 more columns to the end). I would like to "update" the same columns...
Code I use to Load XML file:
Code:
VB.NET:
Dim name As String
name = IDTextBox.Text
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create(Application.StartupPath & "\Data\" & Name & ".xml", New XmlReaderSettings())
Dim ds As New DataSet
ds.ReadXml(xmlFile)
DataGridView1.DataSource = ds.Tables(0)
Is there a way to load the XML data to my datagridview without binding the datagridview to the XML file?
I mean without the use of the:
Code:
VB.NET:
DataGridView1.DataSource = ds.Tables(0)