Xceed Grid for WinForms v4.3 Documentation
How to fix (freeze) columns

Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Appearance > How to fix (freeze) columns

As of version 3.1, Xceed Grid for WinForms supports fixed columns. Programmatically, a column can be fixed by setting its Fixed property to true. At runtime, a column can be fixed by moving it to the left of the FixedColumnSplitter, or by moving the fixed column splitter (all columns to the left of the fixed column splitter will be fixed). 

Programmatically, when a column is fixed by setting its Fixed property to true, it will be appended to the right of the currently fixed columns. Its VisibleIndex property will not be modified allowing for the column to return to its previous visible index when its Fixed property is set to false

If a column is fixed through user interaction (dragging a column to the left of the fixed column splitter), its VisibleIndex will be modified to reflect its new position. If the column is then "un-fixed" programmatically by setting the Fixed property to false it may or may mot end up in its previous position (since the VisibleIndex property was modified). 

The fixed column splitter is accessible through the GridControl class as well as through the DetailGrid class; each having their own unique instances whose appearance and behavior can be modified. 

The fixed column splitters AllowRepositioning property indicates if it can be moved allowing for fixed columns to be added or removed. The Position property indicates the position of the fixed column splitter which will always be located to the immediate right of the fixed columns. The Position property also reflects the number of fixed columns in the grid. For example, if the grid contains 2 fixed columns, the position of the fixed column splitter will be 2 (zero-based). The Position property can be used to determine the number of fixed columns contained in the grid rather than consulting each Column's Fixed property. 

Each row in the grid that contains cells (CellRow) can chose to always show or show only when there are fixed columns, its portion of the fixed column splitter by setting its ShowFixedColumnSplitter to Always or WhenFixedColumnsExist.  If set to Always the fixed column splitter will always be displayed. In the case where there are no fixed columns, the splitter will be located on the far left of the grid. If set to WhenFixedColumnsExist , the fixed column splitter will appear immediately after the fixed columns.

Demonstration

The following code demonstrates how to fix 2 columns programmatically (as demonstrated in the above image). The code below assumes that a DataSet has been created for the Orders table of the Northwind batabase

VB.NET Copy Code

Dim grid As New GridControl()

grid.Dock = DockStyle.Fill
Me.Controls.Add( grid ) 

grid.DataSource = dataSet11
grid.DataMember = "Orders" 

grid.Columns( "OrderID" ).Fixed = True
grid.Columns( "EmployeeID" ).Fixed = True

C# Copy Code

GridControl grid = new GridControl();

grid.Dock = DockStyle.Fill;
this.Controls.Add( grid ); 

grid.DataSource = dataSet11;
grid.DataMember = "Orders"; 

grid.Columns[ "OrderID" ].Fixed = true;
grid.Columns[ "EmployeeID" ].Fixed = true;