Here is the code to
show another form based on the value in the DataGridView selected cell. You
need to create another form (form2) and will be displayed on clicking the cell
that contains values in the If condition. Please change the new form name in the
code accordingly.
private void
dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
string cellval = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (cellval.Contains("google"))
{
Form2 frm = new Form2(this);
frm.Show();
}
}
}
if (cellval.Contains("google"))
{
Form2 frm = new Form2(this);
frm.Show();
}
}
}
No comments:
Post a Comment