从WPF DataGrid的选定行中检索单元格数据 [英] Retrieving cell data from a selected row of a wpf datagrid

查看:87
本文介绍了从WPF DataGrid的选定行中检索单元格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要一些帮助来从wpf数据网格的选定行中检索单元格数据,而我不知道如何实现这一点.拜托,有人可以帮我解决这个问题吗?如果您知道如何获取数据,也可能会发布一个示例.

在此先感谢!!

Hi,

I need some help retrieving cell data from a selected row of a wpf datagrid and I have no idea on how to achieve this. Please, can someone help me figure this out? Possibly post an example as well if you know how to get the data.

Thanks in advance!!

推荐答案

我认为这
I think this answer by Bigsby[^] might help you.


如果您将FullRow中的SelectionUnit属性.


These code works if you put the SelectionUnit property in FullRow.


private void GetSelectedRowCellValue()
{
    foreach (DataGridRow row in dataGrid1.SelectedItems)
    {
         System.Data.DataRow MyRow = (System.Data.DataRow)row.Item;
         string value = MyRow["columnname"].ToString();
    }
}


这篇关于从WPF DataGrid的选定行中检索单元格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆