dash Posted September 16, 2004 Share Posted September 16, 2004 hi all i need to insert a new row at the end of datagrid in vb.net 2003 programmatically. i am doing it now, but it does not add records in a new row, instead it overwrites the values in the first row. help?? :wacko: tanx Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted September 16, 2004 Share Posted September 16, 2004 I don't think it's possible to do so with the grid directly. You have to add items to the list/dataset you are bound to, and possibly rebind. Link to comment Share on other sites More sharing options...
0 Josh Posted September 16, 2004 Share Posted September 16, 2004 correct. Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted September 16, 2004 Share Posted September 16, 2004 For the record, I hate that grid. :D <hugs Infragistics UltraGrid> Link to comment Share on other sites More sharing options...
0 dash Posted September 17, 2004 Author Share Posted September 17, 2004 actually, there is dataset behind this grid, and i tried to use the dataset only, but when i write the xmlfile from this dataset, it goes wrong. it overwrites the firsts record in the xml file along with adding new records. when i call the "WRITEXML" method of the dataset> it should write each chanched record, it does but it also over writes the 1st record with the last record, so i get 2 identical records at the begining of xml and at the end of it. that's why i want to use datagrid. i beleive these are bugs in vs.net 2003. but when i use datagrid the problem of similar records is illiminated, but i cant figure out how to add new rows containing data to the datagrid programatically. is there a way to tell the datagrid to use the new row. i mean something like "begin edit"?? thanks Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted September 17, 2004 Share Posted September 17, 2004 It would greatly help diagnose what's wrong if you posted some code. That said, I said in my previous post what I thought you'd need to do in order to get the grid to show changes. Rebind to it. Link to comment Share on other sites More sharing options...
0 dash Posted September 23, 2004 Author Share Posted September 23, 2004 actually i am uising grid just bcoz i want to store the values in the dataset which is bound to datagrid, in the XML file. but dataset.writexml is not working correctly. so i need to use the grid and write to xml from grid. grid is not visible. Dim b As Integer = Me.BindingContext(Dset, "contact").Position = Me.BindingContext(Dset, "contact").Count Me.BindingContext(Dset, "contact").AddNew() Dim a As Integer = b DG.Item(a, 0) = lblID.Text DG.Item(a, 1) = txtFname.Text DG.Item(a, 2) = txtLname.Text DG.Item(a, 3) = txtAddress.Text DG.Item(a, 4) = txttelhome.Text DG.Item(a, 5) = txtTelOff.Text DG.Item(a, 6) = txtMobile.Text DG.Item(a, 7) = txtFax.Text DG.Item(a, 8) = txtnick.Text DG.Item(a, 9) = txtMSN.Text DG.Item(a, 10) = txtYahoo.Text DG.Item(a, 11) = txtemail1.Text DG.Item(a, 12) = txtemail2.Text DG.Item(a, 13) = txtHID.Text DG.Item(a, 14) = txtDate.Text DG.Item(a, 15) = txtage.Text DG.Item(a, 16) = txtcompany.Text DG.Item(a, 17) = txtprofession.Text DG.Item(a, 18) = txtnationality.Text DG.Item(a, 19) = CMBGroup.SelectedItem DG.Item(a, 20) = txtnotes.Text DG.BindingContext.Item(Dset, "contact").AddNew() Dset.WriteXml("../xbdata.xml") Link to comment Share on other sites More sharing options...
Question
dash
hi all
i need to insert a new row at the end of datagrid in vb.net 2003 programmatically.
i am doing it now, but it does not add records in a new row, instead it overwrites the values in the first row. help?? :wacko:
tanx
Link to comment
Share on other sites
6 answers to this question
Recommended Posts