[Go] the WPF DataGrid gets the value of a column in the selected row.
Method 1:
DataRowView mySelectedElement = (DataRowView) dataGrid1.SelectedItem;
String result = mySelectedElement. Row [0] ToString ();
Method 2:
Var a = this. dataGrid1.SelectedItem;
Var B = a as DataRowView;
String result = B. Row [0]. ToString ();
The wpf datagrid is bound to data. How can I obtain the value of a column in the selected row from multiple selected rows?
DataRowView selectItem = explorird. SelectItem as DataRowView;
Object obj = selectItem ["columnName"] or selectItem [index];
How does one obtain the value of the currently selected row in the WPF DataGrid?
DataGrid1.SelectedItem is the data entity object represented by the row selected by your dataGrid
You can obtain and set attributes of this object in the following ways:
(DataGrid1.SelectedItem as object). Attribute
I don't quite understand what textbox you are referring. By default, data in the table can be modified on the foreground. If you want to change the bound data source, you only need to set two-way binding.