True DBGrid 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:
Fired upon an attempt to edit column data. | |
Fired when the current cell enters edit mode. | |
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:
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
· C#
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 = "";
}
· Delphi
procedure TWinForm.C1TrueDBGrid1_ColEdit(sender: System.Object; e: C1.Win.C1TrueDBGrid.ColEventArgs);
var S: string;
begin
S := Self.C1TrueDBGrid1.Columns[e.ColIndex].Caption;
if (S = 'Code') then;
Self.Label1.Text := 'Enter 4-digit company code';
else if (S = 'Description') then
Self.Label1.Text := 'Enter full company name';
end;
procedure TwinForm.C1TrueDBGrid1_AfterColEdit(sender: System.Object; e: C1.Win.C1TrueDBGrid.ColEventArgs);
begin
// Clear editing instructions.
Self.Label1.Text := '';
end;
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |