JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Okay,
So i've got a form, with a DataGridView, and all my tableadapters and bindingsource, with a listbox that is populated at load with all my tables from my DataSet. This part works great. You click on the table in the lost box and I set the appropriate datamember for the BindSource to the right table from my DataSet and voila, the DataGridView now shows the table in full glory.
But as with many database "grids" and what not, there is that last row with the asterisk (*) in the row header, and there I can start adding new rows. But, when I'm done adding the data into the row, it doesn't update the DataSet (or maybe it does) and thus subsequently does not update the actual database table. So when i click on a table, load it into the DGV, enter in a new row or two, then click to another table and back, the table i "supposedly" changed hasn't altered in any way.
So, my question is in what events or what not is it pertinent to listen to the DGV, the BindingSource, or even the dataSet partial class you can create to determine that in the bound control i have added a row, and thus can either:
I"m still a bit new to the the whole linking a database into a VB application in such a manner. I'm much more familiar with oracle sql and running through a sql client like sql*plus or pl/sql developer, so the linking of controls to the database connection is a bit strange still. I'm not sure i"m even going to allow the DGV to directly edit the tables, i'm just curious right now (as a process of learning) how I would do it, given a DataSource and DataMember for the DGV pointing to a DataSet with DataTable.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
ps
I've tested these methods:
The above is the vb source for the stongly typed DataSet created by the XSD file designer into the code for additional handling. That even fires the moment I enter (click on) the "new" row on the DGV.
This event fires the moment i type in the dgv's "new row". I guess i just need some help in tying together the events with the actions necessary to take the new data and insert it into the table.
Thanks
So i've got a form, with a DataGridView, and all my tableadapters and bindingsource, with a listbox that is populated at load with all my tables from my DataSet. This part works great. You click on the table in the lost box and I set the appropriate datamember for the BindSource to the right table from my DataSet and voila, the DataGridView now shows the table in full glory.
But as with many database "grids" and what not, there is that last row with the asterisk (*) in the row header, and there I can start adding new rows. But, when I'm done adding the data into the row, it doesn't update the DataSet (or maybe it does) and thus subsequently does not update the actual database table. So when i click on a table, load it into the DGV, enter in a new row or two, then click to another table and back, the table i "supposedly" changed hasn't altered in any way.
So, my question is in what events or what not is it pertinent to listen to the DGV, the BindingSource, or even the dataSet partial class you can create to determine that in the bound control i have added a row, and thus can either:
- Commit the new row to the database
- Cancel the added data
I"m still a bit new to the the whole linking a database into a VB application in such a manner. I'm much more familiar with oracle sql and running through a sql client like sql*plus or pl/sql developer, so the linking of controls to the database connection is a bit strange still. I'm not sure i"m even going to allow the DGV to directly edit the tables, i'm just curious right now (as a process of learning) how I would do it, given a DataSource and DataMember for the DGV pointing to a DataSet with DataTable.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
ps
I've tested these methods:
VB.NET:
Partial Class dsRexamShip
Partial Class tblLocationDataTable
Private Sub tblLocationDataTable_TableNewRow(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) Handles Me.TableNewRow
MsgBox("Adding a new row?", , "RexamClean")
End Sub
End Class
end class
VB.NET:
Private Sub dgvResult1_UserAddedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles dgvResult1.UserAddedRow
SQLText.AppendText("User Added Row")
End Sub
Thanks
Last edited: