方法一:DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem; string result = mySelectedElement.Row[0]ToString(); 方法二:var a = this.dataGrid1.SelectedItem; var b = a as DataRowView;string result = b.Row[0].ToString();
方法一: DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem; ]ToString(); 方法二: var a = this.dataGrid1.SelectedItem; var b = a as DataRowView; ].ToString();
一:根据数据源类型获取选中项 类: public class Region { public int REGION_ID { get; set; } public string REGION_CODE { get; set; } public string REGION_NAME { get; set; } public int PARENT_ID { get; set; } } 数据源绑定: //绑定国家 cbe_Nationality.ItemsSource = new List<Regio
在WPF中,单击DataGrid,如何获取当前点击的行? 比如在MouseDoubleClick事件中,事实上获取的选中行是一个DataRowview,你可以通过以下的方法来获取选中行的数据,需要引用system.IO 和System.Data; var a =this.exDataGrid.selectItem; var b= a as DataRowView; 或者var b=(DataRowView) exDataGrid.selectItem b["FiledName"].To
[0]是指当前行第1列的单元格位置 注意:DataRowView要求必须引用System.Data命名空间 方法一: DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem; int result = Convert.ToInt32(mySelectedElement.Row[0]); 方法二: var a = this.dataGrid1.SelectedItem;var b = a as DataRowView;