Stanislav
2021-04-02T13:05:55Z
Hello,

I am using several different user controls for editing cells in an iGrid in a C# WinForms application (via iGCellEditorBase-derived classes), and am having issues processing standard Escape, Enter and Tab keys when a cell is being edited. I am using iGrid v.5.

When a control is derived from a simple WinForms control, there is no problem - Escape, Enter and Tab keys work as expected, with input returning to the grid.

This is different with UserControls. As far as I can see from "iGrid Editing.cs" in iGrid source code, iGrid uses PreviewKeyDown and KeyDown event handlers of the edit control in order to implement input focus with these keys. However, UserControls do not even fire PreviewKeyDown and KeyDown events, and instead all of these are handled by child controls.
So far I have been able to use the protected ProcessCmdKey() method of the usercontrol to return focus to the parent grid when these keys are pressed, thus committing the current value to the grid. However, this requires me to add code to all usercontrols that will be used for grid cell editing and is not good engineering.

The 2nd approach to cell editing, as explained in "Non-iGCellEditorBase-based Approach" section of the documentation, will also require similar workarounds because I will still need to capture the above keys inside the usercontrol.

Can you recommend any other solution? Perhaps in newer versions of iGrid?

Thanks a lot!

Best regards,
Stanislav
Igor/10Tec
2021-04-02T14:44:56Z
The problem of the KeyDown event for UserControls is discussed on many Internet forums. One of them I've just found is this . The answer is that UserControls were designed to be containers for other controls. As such, they will always have this problem with the KeyDown event and you will always need to write extra code to solve it. Perhaps, you should think about using another architecture for your custom cell editors.