ComponentOne True DBGrid for WinForms
Moving to the AddNew Row
True DBGrid for WinForms Task-Based Help > Moving to the AddNew Row

To make the AddNew row the active row when the program runs, use the AllowAddNew property, and the MoveLast and Select methods.

Complete the following steps:

  1. Set the AllowAddNew property to True either in the Properties window or by adding the following code to the Form_Load event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.AllowAddNew = True
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.AllowAddNew = true;
    
  2. Move to the last record in the grid by adding following code to the Form_Load event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.MoveLast()
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid.MoveLast();
    
  3. Move to the AddNew row by adding following code to the Form_Load event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Row = Me.C1TrueDBGrid1.Row + 1
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.Row = this.c1TrueDBGrid1.Row + 1;
    
  4. Set focus to the grid by adding following code to the Form_Load event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Select()
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.Select();
    

What You've Accomplished

When the program runs, the active row is the AddNew row: