I have a dataGridView1 and the User can enter infos to it, then by clicking a button3 I want him to search for whatever he types in a textBox3 And to get a MessageBox saying if the string was found or not in the datagridview.
This is my code
private void button3_Click(object sender, EventArgs e)
{
bool j = false;
foreach (DataGridViewRow rows in dataGridView1.Rows)
{
for (int i = 1; i < rows.Cells.Count; i++)
{
if(j == false)
{
if (textBox3.Text == rows.Cells[i].Value.ToString())
{
j = true;
}
}
else
{
break;
}
}
}
if (j == true)
{
MessageBox.Show("It exists!");
}
else
{
MessageBox.Show("It doesn't exist!!");
}
}