DataGridView Cell on KeyUp event validation

Answered
0
0

Hi team,

In need DataGridView Cell on KeyUp event for validation and in database store purposes.

Why I need it: I need it so that I handle any user input (any key user pressed in the data grid currently edited cell) without to have explicit SAVE button and without explaining the user that he/she needs to leave the current editing cell in order his/her data to be properly stored in to database.

It is very important for my user data handling UI scenario.

Can this be done?

Great thanks!

Best Regards!

  • You must to post comments
Best Answer
0
0

Hi,

I would recommend handling the CellValidated/CellValidating events and do the validation and saving there.
Or handle the CellBeginEdit/CellEndEdit events.
If you really intend to save on any keystroke, you might want to look into using a Custom Cell Editor.

Best regards
Frank

  • You must to post comments
0
0

There is an alternative (and easier approach):

keyup
Alternatively you can remove the handler on CellEndEdit using this.dataGridView1.EditingControl

Please find a small sample attached.

Best regards
Frank

  • mgmst
    • mgmst
    • Apr 24, 2023 - 5:14 pm
    Thank you , but your sample works only on second key stroke.
  • You must to post comments
0
0

I really intend to validate and save on any keystroke.

Can you please suggest some example for custom cell editor.

Thank you!

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.