Edit this page

Frozen Columns

RadGridView provides an easy way to select one or more columns and exclude them from the horizontal scrolling. The frozen columns stay static on top of the horizontal scrolling. To freeze a column, the user has to drag the frozen columns separator.

Rad Grid View Frozencolumns 1

Once there is a frozen column, you can freeze other columns by dragging their headers behind the frozen columns separator.

Rad Grid View Frozencolumns 2

Similarly, you can unfreeze columns by dragging their headers outside the frozen columns separator.

A frozen column always stays on top of horizontal scrolling.

Rad Grid View Frozencolumns 3

Freezing Columns

You can freeze columns programmatically using the FrozenColumnCount property of the RadGridView control. The property is numeric and you have to set it to the number of columns you wish to freeze.

In Example 1, the first two columns are frozen starting from left to right.

Example 1: Setting FrozenColumnCount

<telerik:RadGridView FrozenColumnCount="2" />

Example 1: Setting FrozenColumnCount

this.radGridView.FrozenColumnCount = 2;
Me.radGridView.FrozenColumnCount = 2

Disabling Frozen Columns

To disable the freezing of a column, just set the CanUserFreezeColumns to False (as shown in Example 2) and the frozen columns separator will disappear.

Example 2: Disabling Frozen Columns

<telerik:RadGridView x:Name="radGridView"
             CanUserFreezeColumns="False" />

Rad Grid View Frozencolumns 4

Hiding the Frozen Columns Splitter

You can set the FrozenColumnsSplitterVisibility property of the RadGridView control in order to hide/show the frozen columns splitter.

The property has one of three values:

  • Visible: Displays the element.
  • Hidden: Does not display the element, but reserves space for the element in the layout.
  • Collapsed: Does not display the element, and does not reserve space for it in the layout.

Figure 1: FrozenColumnsSplitterVisibility set to Visible and Hidden/Collapsed, respectively

FrozenColumnsSplitterVisibility="Visible"
FrozenColumnsSplitterVisibility="Hidden"

Frozen Columns Events

As of R1 2016, we've added the FrozenColumnsChanged event which is fired whenever columns are frozen or unfrozen.

Example 3 shows that you can subscribe to the event either declaratively or at runtime like this:

Example 3: Subscribing to the FrozenColumnsChanged Event

<telerik:RadGridView x:Name="gridView"
             FrozenColumnsChanged="gridView_FrozenColumnsChanged" />

Example 3: Subscribing to the FrozenColumnsChanged Event

gridView.FrozenColumnsChanged += new EventHandler<FrozenColumnsChangedEventArgs>(gridView_FrozenColumnsChanged);
AddHandler Me.gridView.FrozenColumnsChanged, AddressOf gridView_FrozenColumnsChanged

Via the FrozenColumnsChangedEventArgs, you can get the:

  • AddedFrozenColumns - the columns that were added to the collection of frozen columns

  • RemovedFrozenColumns - the columns that were removed from the collection of frozen columns

  • AllFrozenColumns - the collection of frozen columns

Example 4 shows how you can get the names of the columns currently in the frozen columns collection as well as the columns added or removed from it.

Example 4: Using the FrozenColumnsChanged Event

private void gridView_FrozenColumnsChanged(object sender, Telerik.Windows.Controls.GridView.GridView.FrozenColumnsChangedEventArgs e)
{
    var msg = "Added: " + string.Join(", ", e.AddedFrozenColumns.Select(x => x.UniqueName)) +
        "\nRemoved: " + string.Join(", ", e.RemovedFrozenColumns.Select(x => x.UniqueName)) +
        "\nAll: " + string.Join(", ", e.AllFrozenColumns.Select(x => x.UniqueName));
    MessageBox.Show(msg);
}
Private Sub gridView_FrozenColumnsChanged(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridView.GridView.FrozenColumnsChangedEventArgs)
    Dim msg = "Added: " & String.Join(", ", e.AddedFrozenColumns.Select(Function(x) x.UniqueName)) & ControlChars.Lf & "Removed: " & String.Join(", ", e.RemovedFrozenColumns.Select(Function(x) x.UniqueName)) & ControlChars.Lf & "All: " & String.Join(", ", e.AllFrozenColumns.Select(Function(x) x.UniqueName))
    MessageBox.Show(msg)
End Sub

Rad Grid View FrozenColumnsChanged 1
Rad Grid View FrozenColumnsChanged 2

See Also