Skip to main content

TcxCustomGridTableView.OnEditKeyDown Event

Occurs when an end-user presses a key while a cell editor is active.

Declaration

property OnEditKeyDown: TcxGridEditKeyEvent read; write;

Remarks

This event fires before the OnEditKeyPress and OnEditKeyUp events are generated, and enables you to perform specific actions before the pressed key is passed to the currently active cell editor.

The Sender parameter references the View.

The AItem parameter identifies the grid item whose value is being edited.

The AEdit parameter references a cell editor.

The Key parameter specifies the pressed key. If the key corresponds to an action to be performed by the editor or View (such as opening the editor’s dropdown window, the grid’s cell navigation or record management via the keyboard), you can pass 0 to this parameter to prevent the key from being processed. The following table lists the actions that can be prohibited in this manner.

Virtual Key Code Associated Action
VK_RETURN Posts a cell editor’s value to a data store.
VK_ESCAPE Closes a cell editor and discards changes to its value.
VK_INSERT Inserts a new grid record.
VK_DELETE Deletes the currently active grid record.
VK_TAB Applies changes to a cell editor’s value and moves focus to the next cell.
VK_LEFT Moves the cursor one character left.
VK_RIGHT Moves the cursor one character right.
VK_UP In the grid, posts a cell editor’s value to a data store and moves focus to the previous grid record. In spin editors, this key code corresponds to an increment operation.
VK_DOWN In the grid, posts a cell editor’s value to a data store and moves focus to the next grid record. In spin editors, this key code corresponds to a decrement operation.
VK_PRIOR In the grid, posts a cell editor’s value to a data store and moves focus up to the first fully visible grid record. If this record is currently active, focus is moved up by the number of grid records that are currently displayed in the view. In spin editors, this key code corresponds to a fast increment operation.
VK_NEXT In the grid, posts a cell editor’s value to a data store and moves focus down to the last fully visible grid record. If this record is currently active, focus is moved down by the number of grid records that are currently displayed in the view. In spin editors, this key code corresponds to a fast decrement operation.

Alphanumeric keys are automatically interpreted as a cell editor’s input and cannot be cancelled by passing 0 as the Key parameter. To accomplish this, handle the OnEditKeyPress event instead.

The Shift parameter determines the state of the mouse buttons and the Alt, Ctrl, and Shift keys.

The following code snippet demonstrates how to display a popup window for dropdown editors by pressing the F10 key.

procedure TMyForm.tvEditKeyDown(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_F10 then
    if AEdit is TcxCustomDropDownEdit then
    begin
      TcxCustomDropDownEdit(AEdit).DroppedDown := True;
      Key := 0;
    end;
end;
See Also