0

I have browsed this and other sites, but not found a solution. Any tips/pointers are appreciated.

Use case: add a new row to a DataGridView, allow user to enter data cell by cell in this new row. When ENTER is clicked in each cell, data goes through validation.

If validation passes, cell becomes readonly, focus moves to the next cell.

If validation fails, an error message appears in the status bar, focus remains on the cell, and cell remains in edit mode, allowing the user to amend the data.

Which events should be handled? What should the body of the handler be? I've experimented with CellValidating/BeginEdit/EndEdit but not been successful.

Arvind
  • 93
  • 8
  • Winforms or WPF? – Robert Harvey Nov 19 '19 at 21:07
  • seem like winform! – MarioWu Nov 20 '19 at 04:44
  • WinForms. I made some progress, documenting it here. Please validate or suggest a better solution. – Arvind Nov 22 '19 at 01:18
  • 1. EditMode.EditProgrammatically 2. BeginEdit() 3. To capture the ENTER key, subclass DataGridView, and override ProcessDialogKey and ProcessDataGridViewKey. 4. If ENTER is received, validate input. If valid input, EndEdit(); if not, display error message, and remain in edit mode. This is the overall approach. If there is interest, can post code snippets. – Arvind Nov 22 '19 at 01:27

0 Answers0