RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomDBGrid.KeyDown Method

Provides special processing when the user presses down on a key.

Pascal
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
C++
virtual __fastcall KeyDown(Word Key, TShiftState Shift);

Applications cannot call KeyDown. It is called automatically when the user presses a key, before the KeyPress method is called.  

KeyDown generates an OnKeyDown event and then responds to the following keystrokes:

Keystroke 
Response 
UpArrow  
Move to the previous row. If Options includes dgRowSelect, select it.  
Ctrl+UpArrow  
Move to the first row in the grid. Deselect any selected rows.  
DownArrow  
Move to the next row. If Options includes dgRowSelect, select it.  
Ctrl+DownArrow  
Move to the last row in the grid. Deselect any selected rows.  
PageUp  
Move up by the number of records shown in the grid. Deselect any selected rows.  
Ctrl+PageUp  
Move to the first row in the grid. Deselect any selected rows.  
PageDown  
Move down by the number of records shown in the grid. Deselect any selected rows.  
LeftArrow  
Move left one column. If Options includes dgRowSelect, move to the previous row without selecting it.  
Ctrl+LeftArrow  
Move to the first column in the current row.  
RightArrow  
Move right one column. If Options includes dgRowSelect, move to the next row without selecting it.  
Ctrl+RightArrow  
Move to the last column in the current row.  
Home  
Move to the first column of the current row. If Options includes dgRowSelect or the grid has only one column, move to the first record in the dataset. Deselect any selected rows.  
Ctrl+Home  
Move to the first record in the dataset. Deselect any selected rows.  
End  
Move to the last column of the current row. If Options includes dgRowSelect or the grid has only one column, move to the last record in the dataset. Deselect any selected rows.  
Ctrl+End  
Move to the last record in the dataset. Deselect any selected rows.  
Tab  
Move to the next cell in the grid.  
Shift+Tab  
Move to the previous cell in the grid.  
Ctrl+Delete  
Delete the current selection.  
Insert  
Insert a new row above the current one, and move to it. Deselect any selected rows.  
Escape  
Cancel any unposted edits. Deselect any selected rows.  
F2  
Put the grid in edit mode.  

 

KeyPress 

Options 

OnKeyDown

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!