Was putting this in a comment but it's easier as a solution ...
Further to SA's solution (which I do not disagree with in any way!)
Are you getting confused between "Columns" and "Cells"?
If a DataGridView has 2 "columns" then in the click event you can capture which "column" was clicked ... it is the Cell index on the row, and is passed in as
e.ColumnIndex
.
You can still access the other "columns" in the datagrid in the same event, you just have to know their column (Cell) index ...
For example, you could click on any column in the row but check if the first column matches the text ... using your code sample this would look like
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewCell cell = (DataGridViewCell)dataGridView2.Rows[e.RowIndex].Cells[0];
if (cell.ValueType.ToString() == "Abhinav")
{
MessageBox.Show("Right Name");
}
else
{
MessageBox.Show("Wrong Name");
}
}