FlexGrid for WinForms Task-Based Help > Freezing Rows and Columns |
To allow the user to freeze rows and columns with the mouse, set the AllowFreezing property to Columns to freeze only columns, Rows to freeze only rows, or Both to freeze both columns and rows. Conversely, to disable freezing, set the AllowFreezing property to None, which is the default setting. This property can be set either in the designer or in code.
Locate the AllowFreezing property in the Properties window and set it to Both.
Add the following code to the Form_Load event to set the AllowFreezing property to Both:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.AllowFreezing = C1.Win.C1FlexGrid.AllowFreezingEnum.Both |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.AllowFreezing = C1.Win.C1FlexGrid.AllowFreezingEnum.Both; |
When the mouse pointer becomes the lock rows or the lock columns
icon, click and drag the mouse over the rows or columns to freeze. In this example, the Element column is frozen and will remain on the grid when it is scrolled to the right.
In this example, the row containing Hydrogen is frozen and will remain on the grid when it is scrolled to the bottom.
![]() |
Note: Setting the AllowFreezing property to Both allows both rows and columns to be frozen at the same time, as seen in the following image. |