Datagrid view: selected cell\column

Hi guys,

I need to find out the value of the selected cell and also the column name to which the cell belongs.

I'd appreciate any code examples or links for the API with examples. I looked on MSDN, couldn't find anything to solve my problem.

Thank you
Who is Participating?
UnifiedISConnect With a Mentor Commented:
datagridview1.columns(e.columnindex).name will tell you the column name
UnifiedISConnect With a Mentor Commented:
The cellclick event of the datagridview exposes the rowindex  and columnindex (e.rowindex, e.columnindex).
get the row:
dim dgr as datagridviewrow = datagridview1.rows(e.rowindex)
get the column within the row:

or datagridview1.rows(e.rowindex).cells(e.columnindex).value
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.