Write the desired word is displayed in the text box. I want to have multiple rows...but, by this code I get only one row selected.. and I want to output to the screen rows.. Rather than painted, I want to display only the rows that specified (match to the Text box's text). How to achieve this?
try
{
dataGridView1.ClearSelection(); //or restore rows backcolor to default
for (int i = 0; i < (dataGridView1.Rows.Count); i++)
{
for (int j = 0; j < (dataGridView1.Columns.Count); j++ )
if (dataGridView1.Rows[i].Cells[j].Value.ToString().StartsWith(txbSearchName.Text, true, CultureInfo.InvariantCulture))
//(dataGridView1.Rows[i].Cells[j].Value.ToString().StartsWith(txbSearchName.Text, true, CultureInfo.InvariantCulture))
{
dataGridView1.FirstDisplayedScrollingRowIndex = i;
dataGridView1.Rows[i].Selected = true; //It is also possible to color the row backgroud
return;
}
}
}
catch (Exception)
{
MessageBox.Show("not exist");
}