Which event is occuring in DataGridView in edit mode when user pressed 'Enter'?
-
When user is editing a DataGridView cell I can not find a way to capture event when user presses 'Enter' key. In OnCellEndEdit there is no way to see which button was pressed, OnKeyDown and OnKeyPress simply do not detect 'Enter' key, they act as if it wasn't even pressed. If I try to add event handler to editing control by getting the control in EditingControlShowing and then adding event handler KeyPress or KeyDown on editing control, it also acts as if 'Enter' wasn't pressed. I've tried googling on this, but can't find it anywhere. I'd appreciate any help or hint on this. Dragan Matic
-
When user is editing a DataGridView cell I can not find a way to capture event when user presses 'Enter' key. In OnCellEndEdit there is no way to see which button was pressed, OnKeyDown and OnKeyPress simply do not detect 'Enter' key, they act as if it wasn't even pressed. If I try to add event handler to editing control by getting the control in EditingControlShowing and then adding event handler KeyPress or KeyDown on editing control, it also acts as if 'Enter' wasn't pressed. I've tried googling on this, but can't find it anywhere. I'd appreciate any help or hint on this. Dragan Matic
Hello Dragan, You can try the following code under the KeyPress() event.
If Asc(e.KeyChar) = 13 Then MsgBox("Enter Pressed") End If
I hope this helps. Regards, AllenAllen Smith Software Engineer ComponentOne LLC www.componentone.com
-
Hello Dragan, You can try the following code under the KeyPress() event.
If Asc(e.KeyChar) = 13 Then MsgBox("Enter Pressed") End If
I hope this helps. Regards, AllenAllen Smith Software Engineer ComponentOne LLC www.componentone.com
No, that's the catch. Once you start editing text in the DataGridView cell and press Enter (when you want to finish editing), it isn't caught in either KeyPress, KeyDown or any other Key event. Well I suppose it is caught somewhere but I can't find where. Thanks for the answer, anyway Dragan