| Cell Editing Techniques > Handling Editing Events > Column Editing Events |
True DBGrid for WinForms provides full control over the cell editing process with the following events, listed in the order in which they occur during a successful editing attempt:
| Event | Description |
|---|---|
| BeforeColEdit | Fired upon an attempt to edit column data. |
| ColEdit | Fired when the current cell enters edit mode. |
| AfterColEdit | Fired after column data is edited. |
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. Use these two events to provide additional feedback while editing is in progress:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub C1TrueDBGrid1_ColEdit(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ColEventArgs) Handles C1TrueDBGrid1.ColEdit
Select Case e.Columns.DataColumn.Caption
Case "Code"
Me.Label1.Text = "Enter 4-digit company code"
Case "Description"
Me.Label1.Text = "Enter full company name"
End Select
End Sub
Private Sub C1TrueDBGrid1_AfterColEdit (ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ColEventArgs) Handles C1TrueDBGrid1.AfterColEdit
' Clear editing instructions.
Me.Label1.Text = ""
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void C1trueDBGrid1_ColEdit(object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)
{
switch(e.Columns.DataColumn.Caption)
{
Case "Code":
this.Label1.Text = "Enter 4-digit company code";
break;
Case "Description";
this.Label1.Text = "Enter full company name";
break;
}
}
private void C1TrueDBGrid1_AfterColEdit(object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)
}
// Clear editing instructions.
this.Label1.Text = "";
}
|
|