Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "commit" a newly created datagrid row to underlying dat

Status
Not open for further replies.

keyser456

IS-IT--Management
Nov 21, 2003
73
US
Ok, I have an event set to fire when I right click on any cell in the datagrid (it will pull up a context menu with the delete option). When I right click on a row that was newly created in the datagrid, the underlying datatable doesn't appear to contain any information at all about this new record now shown in the datagrid (the DataTable.Rows.Count hasn't increased yet). I've tried the DataGrid's EndEdit method with no luck. Basically I'm trying to find a way to delete ANY row in the datagrid using the context menu. So far the code works perfect if you right click on a row that already existed and select delete, or even if you left click on a different row (after creating a new row) and then right click on the new row and select delete. At what point does the datagrid actually send the data to the datatable?
 
N/m, I answered my own question.

this.BindingContext[this.DataSource, this.DataMember].EndCurrentEdit();

I used this in the custom datagrid class and it applies the changes to the datatable. All is well with the world again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top