Find the current row after a sort: snippet

from the Artful MySQL Tips List


After a sort, the current row may vanish. How to find it?
  BindingManagerBase bm = null;
  bm = DataGridView1.BindingContext[DataGridView1.DataSource, DataGridView1.DataMember];
  DataRow findRow = ((DataRowView)bm.Current).Row;
  int index = DataSet.Tables["mytable"].Rows.IndexOf(findRow);

Last updated 22 May 2009


Return to the Artful MySQL Tips page