datagridview - Get index of selected row

G

Guest

Hi all.

How can i get the index (number) of the selected row in a datagridview.
(just one row can be selected)


Thanks.
 
G

Guest

If you have your index assigned as the datakey field in your datagrid, upon
the selection event, you should be able to use the following code:

YourDataGrid.DataKeys[e.Item.ItemIndex].ToString()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top