[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Grids' (#lcl)

TCustomGrid.KeyPress

Applies the specified key press character to the control.

Declaration

Source position: grids.pas line 1146

protected procedure TCustomGrid.KeyPress(

  var Key: Char

); override;

Arguments

Key

  

Key press character examined in the method.

Description

KeyPress is a method used to apply the character in Key to the grid control. KeyPress is overridden to ensure that a key which originated from the grid control is applied properly to the cell Editor (when needed). It calls the inherited method on entry to signal the OnKeyPress event handler (when assigned).

KeyPress uses the value in EditorKey to determine if Key applies to an active cell Editor on the control. If KeyDown did not flag the value for the Editor control, the following values in Key are handled in the method:

Enter (#13)
Gets and displays the cell Editor when EditMode is False and the column allows editing. This includes signalling the OnSelectEditor event handler (when assigned).
Backspace (^H), and characters in the range #32..#255 (data)
Calls EditorShowChar to apply the key press to the Editor (when editing is enabled).

When Key is handled in the method, it is set to #0 prior to exit.

Remark: The SendCharToEditor implementation in the Windows widgetset was modified in LCL version 4.0. It changed the message delivery mechanism from PostMessageW (asynchronous) to SendMessageW (synchronous) to avoid duplicate or unintentional message delivery to the grid and/or cell editor controls.

See also

TCustomGrid.KeyDown

  

Handles key down events for the grid control.

TCustomGrid.EditorKey

  

Indicates if the last key event was triggered by the cell Editor for the grid control.

TCustomGrid.EditorShow

  

Displays the Editor for the selected cell.

TCustomGrid.EditorCanAcceptKey

  

Returns True if the Editor is able to accept the specified UTF-8 character.

TCustomGrid.EditorIsReadOnly

  

Determines if the current column number is defined as read-only.

TCustomGrid.SelectEditor

  

Gets the cell editor for the current cell, and sets its PopupMenu.

TCustomGrid.OnSelectEditor

  

Event handler signalled to select an Editor control for the current grid cell.

TWinControl.KeyPress

  

Signals the OnKeyPress event handler (when assigned).

TWinControl.OnKeyPress

  

Event handler signalled for character data entered by the user.


Version 4.0 Generated 2025-05-03 Home