//-- function used to reselect the row based on column value
private void ReSelectRow(DataGridView myDataGrid, int iColIndex, string sColValue)
{
/* check to make sure we have a value */
if (myDataGrid != null && sColValue.Length > 0)
{
int iRow;
DataSet myDS = (DataSet)myDataGrid.DataSource;
/* loop through the collection and check the value */
for (iRow = 0; iRow < myDS.Tables[0].Rows.Count; iRow++)
{
string myValue = myDataGrid[iColIndex, iRow].Value.ToString();
if (myValue == sColValue)
{
myDataGrid.Rows[iRow].Selected = true;
myDataGrid.Rows[iRow].Cells[iColIndex].Selected = true;
break;
}
}
}
}