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
Loading
Sam HobbsPosted Mar 29, 2010, 2:13 PM
Or create a DataTable with the data and bind the DataTable with the DataGridView.
You say that you have a DataGridView that is "filling a dataset of 5000 rows". Do you mean filling a DataTable? A DataSet consists of multiple DataTables. Is the DataGridView bound to the DataTable? If so, then use the DataTable to do the search.