I have difficulty in extracting data from datagrid. Since I was using selectionchange event on datagrid. I managed to get the selected row and column index. But I couldn’t find any properties to get the exact data from the datagrid or datagridrow or selectedcells. Hope to get some advice from you guys, cheers.
I have difficulty in extracting data from datagrid. Since I was using selectionchange event
Share
Bind your DataGrid to an ItemsSource containing your data, and then your SelectedItem will be the item in your ItemsSource.
You had a comment above of using ComboBoxes, so here’s an example:
The DataContext for your DataGrid would contain
The
SomeItemclass would have a property ofOptionId, and theOptionclass would havean
IdandNamefield.In this example, when you select an item in the DataGrid the
DataGrid.SelectedItemwould contain theSomeItemRemember, in WPF your Data (DataContext) is your application, and your UI elements like ComboBoxes, TextBoxes, DataGrids, etc are all just a pretty interface to let the user interact with your Data