views:

1045

answers:

2

How do you get row number DataGridView cell? Specifically, if a user has selected a single cell, how can you get that row number? It needs to access a particular cell based on what the user has selected.

I know that the RemoveAt method can be used to remove at the Focus, but you cannot get the row number at focus apparently?

Thanks for the help!

+2  A: 

You can simply use RowIndex on the current cell:

var row = dataGridView1.CurrentCell.RowIndex;
Matt Hamilton
Why didn't I think of that lol? Thanks!
Cyclone
A: 

It is nearly the same but you may also use this solution:

var row = dataGridView1.CurrentRow.Index
mhofer