How do I assign selected WPF datagrid row columns to variables. (VB.NET)
- by Peter
Hi,
I have a datagrid with customer data such as ID, name, email, phone etc.
When I select a row (with a button or selectionchanged) I want to store that row's columns in variables like
dim email as string
dim name as string
email = dgCustomers.theselectedrow.theselectedcell
name = dgCustomers.theselectedrow.theselectedcell
If I have a datatable with only one row I know I can get column data with:
dim email as string = CustomerDataTableInstance.rows(0).Item("Email")
I don't know how to get the selected row number though when I have several rows and the user clicks one/uses the keyboard.
The datagrid is bound to a datatable, not a class with object collections.
Any help is appreciated!