DataGrid CurrentRowChanged ?

  • Thread starter Thread starter Paul Sampson
  • Start date Start date
P

Paul Sampson

Hello,

The DataGrid.CurrentCellChanged requires too much overhead to determine when
only the row has changed.

Can anyone suggest a way to fire an event when the user selects a different
row in a windows forms datagrid?

Perhaps this can be done by examining the underlying DataTable, but I'm yet
to find a way.

Thanks
 
hi paul

the datagrid itself does not have such an event... i guess!
however the DataTable has them!

myDataTable.RowChanged
myDataTable.RowChanging
myDataTable.RowDeleted
myDataTable.RowDeleting

just map these events to a method in your class, and event will fire when
datarow changed on the datagrid!

hope this helps
cheers Jazper
 
Hi Paul,

The simplest (and the most reliable I believe) way would be to override the
OnCurrentCellChanged method in a class inherited from the DataGrid and raise
a custom CurrentRowChanged event whenever the user goes to another row (you
can determine that by analyzing the CurrentCell property and maintaining a
temporary variable storing current row number).
 
Back
Top