RAD Studio
ContentsIndex
PreviousUpNext
Responding to User Actions at Runtime

You can modify grid behavior by writing event handlers to respond to specific actions within the grid at runtime. Because a grid typically displays many fields and records at once, you may have very specific needs to respond to changes to individual columns. For example, you might want to activate and deactivate a button elsewhere on the form every time a user enters and exits a specific column. 

The following table lists the grid events available in the Object Inspector.  

Grid control events  

Event 
Purpose 
OnCellClick  
Occurs when a user clicks on a cell in the grid.  
OnColEnter  
Occurs when a user moves into a column on the grid.  
OnColExit  
Occurs when a user leaves a column on the grid.  
OnColumnMoved  
Occurs when the user moves a column to a new location.  
OnDblClick  
Occurs when a user double clicks in the grid.  
OnDragDrop  
Occurs when a user drags and drops in the grid.  
OnDragOver  
Occurs when a user drags over the grid.  
OnDrawColumnCell  
Occurs when application needs to draw individual cells.  
OnDrawDataCell  
(obsolete) Occurs when application needs to draw individual cells if State is csDefault.  
OnEditButtonClick  
Occurs when the user clicks on an ellipsis button in a column.  
OnEndDrag  
Occurs when a user stops dragging on the grid.  
OnEnter  
Occurs when the grid gets focus.  
OnExit  
Occurs when the grid loses focus.  
OnKeyDown  
Occurs when a user presses any key or key combination on the keyboard when in the grid.  
OnKeyPress  
Occurs when a user presses a single alphanumeric key on the keyboard when in the grid.  
OnKeyUp  
Occurs when a user releases a key when in the grid.  
OnStartDrag  
Occurs when a user starts dragging on the grid.  
OnTitleClick  
Occurs when a user clicks the title for a column.  

There are many uses for these events. For example, you might write a handler for the OnDblClick event that pops up a list from which a user can choose a value to enter in a column. Such a handler would use the SelectedField property to determine to current row and column.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!