[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;
int result = Convert.ToInt32(b.Row[0]);