| True DBGrid for WinForms Task-Based Help > Controlling Grid Interaction > Freezing Columns |
To freeze columns in the grid, set the Frozen property to True. Freezing columns locks them from being scrolled and also prevents all columns with a lesser index from being scrolled. This property can be set either in the designer or in code.
Add the following code to the Form_Load event to freeze the Last column:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1TrueDBGrid1.Splits(0).DisplayColumns("Last").Frozen = True
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1TrueDBGrid1.Splits[0].DisplayColumns["Last"].Frozen = true; |
|
Both the First and Last columns are frozen and will remain on the grid when it is scrolled to the right: