All pastes #19735 Raw Edit

Something

public text v1 · immutable
#19735 ·published 2005-08-10 18:02 UTC
rendered paste body
        private void ReSelectRow(DataGridView myDataGrid, string myValue)
        {
            /* check to make sure we have a value */
            if (myDataGrid != null && myValue.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 sColValue = myDataGrid[1, iRow].Value.ToString();

                    if (sColValue == myValue)
                    {
                        myDataGrid.Rows[iRow].Selected = true;
                        myDataGrid.Rows[iRow].Cells[1].Selected = true;
                        break;
                    }
                }
            }
        }