DataGrid.RowChanged event

Have you ever needed a RowChanged event on a DataGrid so you can detect when the user scrolls through your data?  If so you have probably noticed that there isn't one.

To get to this event you need to go via the CurrencyManager, the following code illustrates how to do this

CurrencyManager cm =
  (CurrencyManager) DataGrid1.BindingContext[***];
cm.PositionChanged +=
  new System.EventHandler(this.DataGridRowChanged);

Where *** is the datasource for the control.  Each time the user changes to a different row the DataGridRowChanged event of your form will be executed.


Share this article!

Follow us!

Find more helpful articles: