且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从WPF DataGrid的选定行中检索单元格数据

更新时间:2023-12-05 10:27:58

我认为这 ^ ]可能会对您有所帮助.
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();
    }
}