ComponentOne DataGrid for WPF and Silverlight
DataGrid for WPF and Silverlight Overview / DataGrid Features / Freezing / Freezing Grid Rows
In This Topic
    Freezing Grid Rows
    In This Topic

    You may want to freeze the top or bottom rows in the grid at so that they are always visible even when the grid is scrolled vertically at run time. This feature is not enabled by default, but if you choose you can enable the row freezing feature by setting the FrozenTopRowsCount and FrozenBottomRowsCount properties.

    At Design Time

    To freeze the top and bottom two rows, complete the following steps:

    1. Click the C1DataGrid control once to select it and navigate to the Properties window.
    2. In the Properties window, locate the FrozenTopRowsCount property, click in the text box next to the property, and enter "2" to set the number of top tows that will be frozen.
    3. Locate the FrozenBottomRowsCount property, click in the text box next to the property, and enter "2" to set the number of bottom rows that will be frozen.

    In XAML

    For example to freeze the top and bottom two rows, add FrozenTopRowsCount="2" FrozenBottomRowsCount="2" to the <c1:C1DataGrid> tag so that it appears similar to the following:

    <c1:C1DataGrid Name="c1datagrid1" Height="180" Width="250" FrozenTopRowsCount="2" FrozenBottomRowsCount="2" />

    In Code

    For example, to freeze the top and bottom two rows, add the following code to your project:

    Visual Basic
    Copy Code
    Me.C1DataGrid1.FrozenTopRowsCount = True
    Me.C1DataGrid1.FrozenBottomRowsCount = True
    

     

    C#
    Copy Code
    this.c1DataGrid1.FrozenTopRowsCount = true;
    this.c1DataGrid1.FrozenBottomRowsCount = true;
    

    What You've Accomplished

    Run the application and observe that the two top and bottom rows are frozen. Scroll the grid vertically and notice that the top two an bottom two rows do not scroll and are locked in place. By default the Add New row appears as the last row in the grid and so will be one of the frozen rows.