Frozen Rows and Columns
When showing tables with many columns, it is often convenient to ‘freeze’ the first few rows or columns so they remain visible when the grid scrolls.
This can be achieved easily by setting the Rows.Frozen and Columns.Frozen properties. By default, the C1FlexGrid will show black lines between the fixed and scrollable areas of the grid (as Excel does). You can use the FrozenLinesBrush property to remove the divider lines or change their color.
The code below shows how you could implement a ‘freeze panes’ command similar to the one in Excel:
// freeze/unfreeze panes
void _chkFreezePanes_Click(object sender, RoutedEventArgs e)
{
if (_chkFreezePanes.IsChecked.Value)
{
_flexGroup.Rows.Frozen = _flexGroup.Selection.Row;
_flexGroup.Columns.Frozen = _flexGroup.Selection.Column;
}
else
{
_flexGroup.Rows.Frozen = 0;
_flexGroup.Columns.Frozen = 0;
}
}
When the user checks the _chkFreezePanes checkbox, the event handler sets the Rows.Frozen and Columns.Frozen properties to keep the rows and columns above and to the left of the current selection always in view.