I have looked at and experimented with a couple of code examples to do this but can't get it quite right. I hate to bother people with things I can do on my own but in this instance I really could use some help because VB2010 is new to me.
I have a datagridview1 on a form plus several textboxes that are used for data calculations.
When the user has performed the calculations to their satisfaction, there is a Button that writes the calculated data to the datagridview1. I would like to keep that button function intact.
What I need to accomplish is saving datagridview1 data and retrieving it. With my limited VB experience it looks to me like writing the data to xml is the correct method. I should then be able to retrieve the data back to the datagridview1 when the form loads so that the user can either add more rows or edit current rows and re-save the data.
May I please have some assistance with this?
I fiddled with this code but can't get the syntax correct to make VB2010 happy....believe me...I fiddled with this for quite a while before I broke down and asked for help
I have a datagridview1 on a form plus several textboxes that are used for data calculations.
When the user has performed the calculations to their satisfaction, there is a Button that writes the calculated data to the datagridview1. I would like to keep that button function intact.
What I need to accomplish is saving datagridview1 data and retrieving it. With my limited VB experience it looks to me like writing the data to xml is the correct method. I should then be able to retrieve the data back to the datagridview1 when the form loads so that the user can either add more rows or edit current rows and re-save the data.
May I please have some assistance with this?
I fiddled with this code but can't get the syntax correct to make VB2010 happy....believe me...I fiddled with this for quite a while before I broke down and asked for help
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim gridtable As DataTable = New DataTable(datagridtable") Dim gridtable_collumn1 As DataColumn = New _ DataColumn("datagridcollumn1") ' [COLOR=#ff0000]I tried changing "datagridcollumnn1" to column1 name of my datagrid[/COLOR] Dim gridtable_collumn2 As DataColumn = New _ DataColumn("datagridcollumn2") gridtable.Columns.Add(gridtable_collumn1) '[COLOR=#ff0000] and also changed it here[/COLOR] gridtable.Columns.Add(gridtable_collumn2) Dim gridrow As DataGridViewRow Dim table_row As DataRow For Each gridrow In datagridview1.Rows table_row = gridtable .NewRow table_row ("datagridcollumn1")=gridrow.Cells("collumn1").Value table_row ("datagridcollumn2")=gridrow.Cells("collumn2").Value gridtable.Rows.Add( table_row) gridtable.WriteXml("test.xml") next gridrow
Last edited: