您的位置:首页 > 其它

DataGrid选中任意一行,获取其中的信息

2016-10-31 20:42 302 查看
DataGrid选中任意一行,获取其中的信息

在网上查了好多资源都得不到想要的结果,甚至还有说,DataGrid是不能精确的选中行和列的。看了好长时间,终于搞出来了,在这里和大家分享下,希望可以给你提供帮助。


//在DataGrid上触发SelectedCellsChanged事件

private void dataGrid_SelectedCellsChanged(object sender,SelectCellsChangedEventArgs e)

{

DataRowView dt = (dataGrid.CurrentItem as DataRowView);

if( dt != null)

{

string id = (dt.Row[0] as string);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: