Nagendra Nagendra - 2 months ago 13
C# Question

Selecting a row in DataGridView programmatically

How can I select a particular range of rows in a

DataGridView
programmatically at runtime?

Answer

Not tested, but I think you can do the following:

dataGrid.Rows[index].Selected = true;

or you could do the following (but agian: not tested):

dataGrid.SelectedRows.Clear();
foreach(DataGridViewRow row in dataGrid.Rows)
{
    if(YOUR CONDITION)
       row.Selected = true;
}