ComponentOne True DBGrid for WinForms
Changing the Column Order in the Grid
True DBGrid for WinForms Task-Based Help > Changing the Column Order in the Grid

To change the column order in the grid, use the C1TrueDBGrid Designer or set RemoveAt and Insert methods in code.

In the Designer

To change the grid column order in the Designer, complete the following steps:

  1. Open the C1TrueDBGrid Designer. For information on how to access the C1TrueDBGrid Designer, see Accessing the C1TrueDBGrid Designer.
  2. In the designer, select the Country column from the right pane.
  3. Click and drag the Country column to the left. A red arrow will appear where the column can be dropped.
  4. Drop the Country column before the First column.
  5. Click OK to close the designer.

In Code

To change the grid column order in code, complete the following steps:

  1. Declare the variable for the Country column by adding the following code to the Form_Load event:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim dispColumn As C1.Win.C1TrueDBGrid.C1DisplayColumn
    dispColumn = Me.C1TrueDBGrid1.Splits(0).DisplayColumns(2)
    

    To write code in C#

    C#
    Copy Code
    C1.Win.C1TrueDBGrid.C1DisplayColumn dispColumn;
    dispColumn = this.c1TrueDBGrid.Splits[0].DisplayColumns[2];
    
  2. Move the Country column before the First column:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Splits(0).DisplayColumns.RemoveAt(2)
    Me.C1TrueDBGrid1.Splits(0).DisplayColumns.Insert(0, dispColumn)
    

    To write code in C#

    C#
    Copy Code
    this.c1TrueDBGrid1.Splits[0].DisplayColumns.RemoveAt(2);
    this.c1TrueDBGrid1.Splits[0].DisplayColumns.Insert(0, dispColumn);
    

What You've Accomplished

The Country column appears in the grid before the First column: