Version

Specifying Fixed Rows

The fixed rows feature allows you to fix (freeze) rows on the top or bottom of the WinGrid™ so that when the grid is scrolled vertically, the fixed rows will not be scrolled out of view. Fixed rows are supported in the root row collection only. They are not currently supported in child bands or when the ViewStyle is set to 'OutlookGroupBy'.

  1. Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.

In Visual Basic:

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

In C#:

using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
  1. You can enable fixed rows in the WinGrid by setting the FixedRowStyle property on the Override property of the grid’s DisplayLayout to one of the FixedRowStyle values. FixedRowStyle specifies whether the fixed rows are displayed at the top or bottom of the row collection.

In Visual Basic:

' Set the FixedRowStyle to Top so that fixed rows will be displayed at the top of the grid.
Me.UltraGrid1.DisplayLayout.Override.FixedRowStyle = FixedRowStyle.Top

In C#:

// Set the FixedRowStyle to Top so that fixed rows will be displayed at the top of the grid.
this.ultraGrid1.DisplayLayout.Override.FixedRowStyle = FixedRowStyle.Top;
  1. In addition to setting the FixedRowStyle property you also need to specify the row(s) you want to be fixed. You can use the following line of code to add a row to the FixedRows collection of the root band.

In Visual Basic:

' Set the first row to be a fixed row
Me.UltraGrid1.Rows.FixedRows.Add(Me.UltraGrid1.Rows(0))

In C#:

// Set the first row to be a fixed row
this.ultraGrid1.Rows.FixedRows.Add(this.ultraGrid1.Rows[0]);

Alternatively, you can set the Fixed property on a row to indicate that it should be fixed. The following code demonstrates this technique:

In Visual Basic:

' Set the first row to be a fixed row
Me.UltraGrid1.Rows(0).Fixed = True

In C#:

// Set the first row to be a fixed row
this.ultraGrid1.Rows[0].Fixed = true;
  1. Setting the FixedRowIndicator property determines if users can fix rows at run-time. Setting this property to 'Button' causes state buttons to be displayed in the row selectors. Those state buttons can be used for fixing and unfixing rows. When the state buttons are displayed in row selectors the row selector width is automatically adjusted to accommodate them. Setting this property to 'None' prevents an indicator from being displayed. The 'Default' value is resolved to 'None'.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.Override.FixedRowIndicator = FixedRowIndicator.Button

In C#:

this.ultraGrid1.DisplayLayout.Override.FixedRowIndicator = FixedRowIndicator.Button;
  1. You can set the AllowFixing property on an UltraGridRow object. This gives you the ability to indicate whether the user can make a row fixed or not on a per row basis.

In Visual Basic:

' Don't allow the end user to fix or unfix this row
Me.UltraGrid1.Rows(0).AllowFixing = Infragistics.Win.DefaultableBoolean.False

In C#:

// Don't allow the end user to fix or unfix this row
this.ultraGrid1.Rows[0].AllowFixing = DefaultableBoolean.False;
  1. You can use the next three Appearance objects off the WinGrid to style the appearance of the rows or cells that are fixed.

  1. The screen shot below shows four fixed rows, with the first one fixed and is not changeable by the end user. The other three can be unfixed by the end user at run time.

specify fixed rows in ultragrid