Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

get selected row column value in datagrid C#

$
0
0

I am currently doing the following to get the key of the row selected in my grid.

 

string CustomerID =

this.grdCustomers[grdCustomers.CurrentRowIndex, 0];

 

I have seen that there is a way in visual basic to use the column name "ID" instead of an index value. Something like this:

 

grdCustomers.selectedRow["ID"]

 

Is it possible to do this in C#. That way if the grid column order is changed it won't affect my code.

 

 


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>