DataGrid detect row changes

  • Thread starter Thread starter Doug Bell
  • Start date Start date
D

Doug Bell

Hi
I have a DataGrid that has a DataView as its DataSource.

I need to detect when a New Row is added or when a Row is Deleted so that I
change data in the underlying DataTable.

I found that MyDataGrid_CurrentCellChanged doesn't fire on a deletion or on
a New Row if there was no previous rows.

Can someone advised the simplest way to detect row additions or deletions?

Thanks
 
Doug

As you are working witht he datagrid, try than to forget change information
from that, try to use the underlying datasource. A change in the datagrid is
not as something is typed (or you should use the textbox for that), however
if there is a rowchange.

It is just more simple to work with the datasource than the cells from the
datagrid.

Cor
 
OK but how do I get a change in the underlying DataTable to trigger an Event
that I can use check and set the (complex) "ID" Column in the DataTable for
the New Row.
 
Try listening to the underly DataView.ListChanged event. (If the
DataSource is a DataTable, this would probably be
DataTable.DefaultView). There you can check for:

if(e.ListChangedType == ListChangedType.ItemAdded)
{
//...
}

Maybe this will picked out the adding of a new row.

================
Clay Burch
Syncfusion, Inc.
 
Oops. Sorry for the C# code.

If e.ListChangedType = ListChangedType.ItemAdded Then
'...
End If
====================
Clay Burch
Syncfusion, Inc.
 
Back
Top