ComponentOne FlexGrid for WinForms
Rows and Columns / Freezing Rows and Columns
In This Topic
    Freezing Rows and Columns
    In This Topic

    To allow the user to freeze rows and columns with the mouse, set the AllowFreezing property of C1FlexGridBase class 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.

    In the Designer

    Locate the AllowFreezing property in the Properties window and set it to Both.

    In Code

    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;
    

    This topic illustrates the following:

    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.


    Snapshot of FlexGrid application depicting frozen rows and columns.

    In this example, the row containing Hydrogen is frozen and will remain on the grid when it is scrolled to the bottom.


    Snapshot of FlexGrid application depicting frozen rows and columns.
    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.
    Note: WinForms .NET 5 Edition has only runtime assemblies. Due to the new design-time model in VS2019 Preview, which is not complete yet from the Microsoft side, we do not supply any special design-time features as of yet. However, some of the controls might show up at design-time and allow editing few properties in the property grid.