faraz akram

faraz akram

  • NA
  • 129
  • 0

datagridview rows selection

Mar 29 2010 9:11 AM

hellow
i have a datagridview control that is filling a dataset of 5000 rows. now i want to select row(s) on any input value. but for this i have to loop through the whole datagrid view rows to find out all matches and selecting them here is the code
for (int i = 0; i < dataGridView1.RowCount; i++)
{

if ((variable.Equals(dataGridView1.Rows[i].Cells[3].Value.ToString())))
{
dataGridView1.FirstDisplayedScrollingRowIndex = i;


dataGridView1.Refresh();

dataGridView1.Rows[i].Selected =
true;
}

else
{
dataGridView1.Rows[i].Selected =
false;

}

}
the abouve code is working fine but its v slow as it has to went through 5000 rows, any effcient way to do the bove.
thanks
fazy
 
 

Answers (1)