To make the AddNew row the active row when the program runs, use the AllowAddNew property, and the MoveLast and Select methods.
1. Set the AllowAddNew property to True.
In the Designer
Locate the AllowAddNew property in the Properties window and set it to True.
In Code
Add the following code to the Form_Load event:
Me.C1TrueDBGrid1.AllowAddNew = True
· C#
this.c1TrueDBGrid1.AllowAddNew = true;
· Delphi
Self.C1TrueDBGrid1.AllowAddNew := True;
2. Move to the last record in the grid by adding following code to the Form_Load event:
Me.C1TrueDBGrid1.MoveLast()
· C#
this.c1TrueDBGrid.MoveLast();
· Delphi
Self.C1TrueDBGrid.MoveLast;
3. Move to the AddNew row:
Me.C1TrueDBGrid1.Row = Me.C1TrueDBGrid1.Row + 1
· C#
this.c1TrueDBGrid1.Row = this.c1TrueDBGrid1.Row + 1;
· Delphi
Self.C1TrueDBGrid1.Row := Self.C1TrueDBGrid1.Row + 1;
4. Set focus to the grid:
Me.C1TrueDBGrid1.Select()
· C#
this.c1TrueDBGrid1.Select();
· Delphi
Self.C1TrueDBGrid1.Select;
This topic illustrates the following:
When the program runs, the active row is the AddNew row.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |