Jack
Jack

Reputation: 161

How to determine which row is clicked in GridView using c#

I have a GridView1 in my form which populate a table from my Database. The columns in my table are

ID NAME EMAIL ADDS

Now I want a user to click on ID Row and show a message in a label which row is clicked by a user. How can I do this? I've been googling for a long time.

Upvotes: 0

Views: 175

Answers (1)

Răzvan Flavius Panda
Răzvan Flavius Panda

Reputation: 22106

You can find out the clicked row/column in the DataGridView.CellClick Event Handler.

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    // e.RowIndex
    // e.ColumnIndex
}

Upvotes: 1

Related Questions