How do I assign selected WPF datagrid row columns to variables. (VB.NET)

Posted by Peter on Stack Overflow See other posts from Stack Overflow or by Peter
Published on 2010-04-18T05:30:05Z Indexed on 2010/04/18 5:33 UTC
Read the original article Hit count: 305

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about vb.net