private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Find Next";
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ProductId"].Value == null)
{
continue;
}
if (row.Cells["ProductId"].Value.ToString().Trim() == textBox1.Text)
{
dataGridView1.CurrentCell = row.Cells["ProductId"];
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows[row.Index].Index;
return;
}
}
}
}