I am creating custom DataGrid
. When i press the keyboard i want to learn CurrentCell
is in edit mode or not. I know how to handle KeyDown
event. I found this and this post. The solutions there didn't help solve my problem. I couldn't find a better way to find out if CurrentCell
is in edit mode or not. How can i achieve this? Is there any solution?
Asked
Active
Viewed 169 times
2

Schia
- 232
- 1
- 11
-
Can you please elaborate on why both of the linked solutions do not solve your problem? – thatguy Aug 17 '20 at 13:15
-
I'm working on a DataGrid of thousands of rows. The solutions there have extra control structures, and some have loops. So when I run the application, checking that one of the cells is in edit mode or not is like a death trap. I needed a better solution that I couldn't find. – Schia Aug 17 '20 at 13:53
1 Answers
2
You could handle the BeginningEdit
and CellEditEnding
and use a variable to keep track of the currently edited cell:
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);
}
You can then use the variable to check whether the cell is currently in edit mode:
if (dataGrid.CurrentCell == _editedCell)
...

mm8
- 163,881
- 10
- 57
- 88