Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在WPF中不使用DataGrid的列名而获得单击的单元格索引_C#_Wpf - Fatal编程技术网

C# 如何在WPF中不使用DataGrid的列名而获得单击的单元格索引

C# 如何在WPF中不使用DataGrid的列名而获得单击的单元格索引,c#,wpf,C#,Wpf,我尝试在WPF中获取特定的单击的单元格索引和DataGrid中的列名,而不使用列名。我想代表DataGrid计算单元值 private void recordDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { object val = recordDataGrid.SelectedValue; object ind = recordDataGrid.SelectedInde

我尝试在WPF中获取特定的单击的单元格索引和DataGrid中的列名,而不使用列名。我想代表DataGrid计算单元值

private void recordDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
    object val = recordDataGrid.SelectedValue;
    object ind = recordDataGrid.SelectedIndex;
    string stringval = val.ToString();
    int n = Convert.ToInt32(ind);
    MessageBox.Show(" " + n + "" + stringval);
}

您的意思是SelectedCells.Last().Column.DisplayIndex?您已经提供了代码。这有什么不对吗?