gpt4 book ai didi

wpf - 如何理解 CurrentCell 在 WPF DataGrid 中是否处于编辑模式?

转载 作者:行者123 更新时间:2023-12-04 09:05:48 24 4
gpt4 key购买 nike

我正在创建自定义 DataGrid .当我按下键盘时,我想学习 CurrentCell是否处于编辑模式。我知道怎么处理 KeyDown事件。我找到了 thisthis邮政。那里的解决方案无助于解决我的问题。我找不到更好的方法来确定 CurrentCell是否处于编辑模式。我怎样才能做到这一点?有什么解决办法吗?

最佳答案

您可以处理 BeginningEditCellEditEnding并使用变量来跟踪当前编辑的单元格:

private DataGridCellInfo _editedCell;

private void DataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{
_editedCell = dataGrid.CurrentCell;
}

private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
_editedCell = default(DataGridCellInfo);
}
然后,您可以使用该变量来检查单元格当前是否处于编辑模式:
if (dataGrid.CurrentCell == _editedCell)
...

关于wpf - 如何理解 CurrentCell 在 WPF DataGrid 中是否处于编辑模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63451411/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com