[SOLVED] DGV EditMode and events

Answered Closed
0
0

Hi,

  1. In DataGridView, no matter what the EditMode is, the behaviour is always onF2OrKeystroke, i.e. editing starts when either pressing F2 (cursor is positioned at the end of current cell value) or any key (current value is deleted and replaced with the pressed key). When tab is pressed to commit changes or Esc to abort changes, the focus is moved to the next cell to the right, NOT in edit mode. If OnEnter is enabled, it would be very useful to allow for continuous editing of cells.
  2. After editing a cell or a row, I would like to commit changes to the database without having to press a save button. However, none of  the following events fires: CellLeave, CellClick, CellEndEdit, RowValidated, RowValidating, RowLeave. Haven’t checked other events, it could of course be that you have postponed their implementation, but just to let you know.

I’m using the ..45 build.

Best,
Alex

  • You must to post comments
Best Answer
0
0

Hi Luca,

You spotted the problem! I was attaching the events and changing the EditMode and then was recreating the DataGridView ! Clever of me ! Duuh

Thanks !

Alex

  • You must to post comments
Great Answer
0
0

Hi Alex,

I can’t reproduce either one. This is the behavior that is built-in and that I get:

  • EditOnF2: You can start editing only by pressing F2 or double click programmatically.
  • EditOnKeystroke: You can start editing by typing or pressing Enter or Space or double click. Enter or space put the cursor at the end.
  • EditOnKeystrokeOrF2: Combination of above.
  • EditProgrammatically: You can start editing only by double click or programmatically.
  • EditOnEnter: The cell enters edit mode immediately with the cursor at the end. Read-only cells get the focus but don’t enter edit mode. Pressing Tab commits the changes and moves you to the next cell or next row, pressing Enter commits and leaves edit mode, pressing Esc restores the cell value and terminates edit mode, pressing left-right arrows moves the cursor in the text until the first or last character and then moves you to the previous or next cell. Pressing up-down doesn’t escape the cell though, by design, and I’m not sure but I think that instead it should move the editing to the cell above or below, like an excel sheet. But some users may get frustrated since in a normal form up-down simply move the cursor to the first or last character.

For the events:

  • They are fired in this order, when tabbing out after editing:  OnCellBeginEdit. OnCellFormatting, OnCellValidating, OnCellValueChanged, OnCellValidated, OnCellEndEdit, OnCellFormatting, OnCellValidating, OnCellValidated, OnCellLeave, OnCellEnter, OnCellFormatting.

I don’t know why you don’t receive the event, they are all fired. Can you please double check that the handlers are attached to the right instance or subclass the grid class?

Let me know.

Best,

Luca

 

  • You must to post comments
Showing 2 results