Compartir a través de


DataGrid.FrozenColumnCount Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the number of columns that the user cannot scroll horizontally.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

Syntax

'Declaration
Public Property FrozenColumnCount As Integer
public int FrozenColumnCount { get; set; }
<sdk:DataGrid FrozenColumnCount="int"/>

Property Value

Type: System.Int32
The number of non-scrolling columns.

Remarks

Dependency property identifier field: FrozenColumnCountProperty

Frozen columns are columns that are always displayed and cannot be scrolled out of visibility. Frozen columns are always the leftmost columns in display order. You cannot drag frozen columns into the group of unfrozen columns or drag unfrozen columns into the group of frozen columns.

Examples

The following code example demonstrates how to set the FrozenColumnCount property in code. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.

Private Sub cbFreezeColumn_Changed(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Dim cb As CheckBox = sender
    If Me.dataGrid1 IsNot Nothing Then
        If cb.IsChecked = True Then
            Me.dataGrid1.FrozenColumnCount = 1
        ElseIf cb.IsChecked = False Then
            Me.dataGrid1.FrozenColumnCount = 0
        End If
    End If
End Sub
private void cbFreezeColumn_Changed(object sender, RoutedEventArgs e)
{
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
    {
        if (cb.IsChecked == true)
            this.dataGrid1.FrozenColumnCount = 1;
        else if (cb.IsChecked == false)
            this.dataGrid1.FrozenColumnCount = 0;
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources