在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
方法一: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();