Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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# 如何在DataGrid中检测单元格点击?_C#_.net_Wpf - Fatal编程技术网

C# 如何在DataGrid中检测单元格点击?

C# 如何在DataGrid中检测单元格点击?,c#,.net,wpf,C#,.net,Wpf,如何检测在DataGrid中单击了哪个特定单元格?您是否尝试处理CellClik或CellContentClick事件?您是否尝试处理CellClik或CellContentClick事件?我很确定您正在查找事件我很确定您正在查找事件假设我也没有找到这个答案,(要确定单元格,请单击)。 假设我想使用它在第一次单击时能够选中/取消选中复选框 那么我猜这个库的设计者不会同意这样做,(我可以用这种方式(取消)选择我的复选框,但这似乎是不明智的/危险的,因为你改变了网格的selected item属性。

如何检测在DataGrid中单击了哪个特定单元格?

您是否尝试处理CellClik或CellContentClick事件?

您是否尝试处理CellClik或CellContentClick事件?

我很确定您正在查找事件我很确定您正在查找事件

假设我也没有找到这个答案,(要确定单元格,请单击)。 假设我想使用它在第一次单击时能够选中/取消选中复选框

那么我猜这个库的设计者不会同意这样做,(我可以用这种方式(取消)选择我的复选框,但这似乎是不明智的/危险的,因为你改变了网格的selected item属性。)

所以我们需要的是有人告诉我们如何检测细胞的点击,否则我们中的一些人
您可能想使用selectionchanged事件,但其缺点是您丢失了有关的信息
按下了网格通道的哪一行

private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (dataGridInstance.SelectedItem != null)
    {
    //do what you need to do with the data. (for example start with:)
    Microsoft.Windows.Controls.DataGridCellInfo datagridCellInfo = dataGridInstance.CurrentCell;

    //when you are done, set selectiTem to null, so even upon a next click on the same          
    //cell this method will be called again
    dataGridTeam.SelectedItem = null;
    }
}

假设我也没有找到这个答案(以确定单元格单击)。 假设我想使用它在第一次单击时能够选中/取消选中复选框

那么我猜这个库的设计者不会同意这样做,(我可以用这种方式(取消)选择我的复选框,但这似乎是不明智的/危险的,因为你改变了网格的selected item属性。)

所以我们需要的是有人告诉我们如何检测细胞的点击,否则我们中的一些人
您可能想使用selectionchanged事件,但其缺点是您丢失了有关的信息
按下了网格通道的哪一行

private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (dataGridInstance.SelectedItem != null)
    {
    //do what you need to do with the data. (for example start with:)
    Microsoft.Windows.Controls.DataGridCellInfo datagridCellInfo = dataGridInstance.CurrentCell;

    //when you are done, set selectiTem to null, so even upon a next click on the same          
    //cell this method will be called again
    dataGridTeam.SelectedItem = null;
    }
}

DataGrid中没有这样的事件:-/DataGrid中没有这样的事件:-/不完全是这样。我需要在选择更改之前检测它。这是用于网页的,对吗?然后你必须为此编写自己的javascript。使用jquery并不难。请看这里的示例@user62658他没有看到标记,正确,但请完全放松pplNot。我需要在选择更改之前检测它。这是针对网页的,对吗?然后你必须为此编写自己的javascript。使用jquery并不难。请参见这里的示例@user62658,他没有看到标记,正确,但请放松ppl