| Cell Editing Techniques > Handling Editing Events > Column editing events |
True DBGrid gives you full control over the cell editing process with the following events, listed in the order in which they occur during a successful editing attempt:
|
Fired upon an attempt to edit column data. |
|
|
Fired when the current cell enters edit mode. |
|
|
Fired after column data is edited. |
You can use the BeforeColEdit event to control the editability of cells on a per-cell basis, or to translate the initial keystroke into a default value.
The ColEdit event signals that the current cell has entered edit mode; the AfterColEdit event signals that edit mode was terminated. You can use these two events to provide additional feedback while editing is in progress:
| Example Title |
Copy Code
|
|---|---|
Private Sub TDBGrid1_ColEdit(ByVal ColIndex As Integer)
Select Case TDBGrid1.Columns(ColIndex).Caption
Case "Code"
Label1.Caption = "Enter 4-digit company code"
Case "Description"
Label1.Caption = "Enter full company name"
End Select
End Sub
Private Sub TDBGrid1_AfterColEdit(ByVal ColIndex As Integer)
' Clear editing instructions.
Label1.Caption = ""
End Sub
|
|