Object Reference > True DBGrid Events > BeforeColEdit Event |
BeforeColEdit Event
The BeforeColEdit event occurs just before the user enters edit mode by typing a character.
TDBGrid_BeforeColEdit (ByVal ColIndex As Integer, ByVal KeyAscii As Integer, Cancel As Integer)
Arguments
ColIndex is an integer that identifies the column about to be edited.
KeyAscii is an integer representing the ANSI key code of the character typed by the user to initiate editing, or 0 if the user initiated editing by clicking the mouse. KeyAscii is passed by value, not by reference; you cannot change its value to initiate editing with a different character.
Cancel is an integer that may be set to True to prevent the user from editing the cell.
If a floating editor marquee is not in use, this event also occurs when the user clicks the current cell or double clicks another cell.
If your event procedure sets the Cancel argument to True, the cell will not enter edit mode. Otherwise, the ColEdit event is fired immediately, followed by the Change and KeyUp events for the KeyAscii argument, if non-zero.
Use this event to control the editability of cells on a per-cell basis.
Note
The KeyAscii argument can only be 0 if a floating editor marquee is not in use.