Version

LevelCount Property

Returns or sets the number of levels that will be displayed for a single record.
Syntax
'Declaration
 
Public Property LevelCount As Integer
public int LevelCount {get; set;}
Remarks

Typically, each data record in a band occupies a single row of the grid, with all of the cells stretching from left to right. In some circumstances, you may want to have a single record occupy more than one row. For example, if you have address data stored in a record, you may want to have the first and last name fields on one level, the street address on a second level, and city, state and postal code fields on a third level. The LevelCount property is used to specify how many levels of data a band will display for each record in the data source.

Levels work in conjunction with groups to create blocks of fields within a band. If you do not have any groups specified for a band, the LevelCount property will have no effect. If one or more groups are specified (and column moving is enabled within the group or band) you can re-arrange fields vertically within the group by dragging their column headers to different levels.

The minimum value for this property is 1. The maximum value for this property is 50. When you specify a value greater than 1 for LevelCount, the control will automatically expand the band to create room for the number of levels you have requested, regardless of whether you actually have cells occupying those levels. Note that if you specify too high a number of levels, the user may initially see only column headers - the data itself may be pushed off the screen and may not be visible. Also, the amount of blank space allocated for each record may break up the visual continuity of the band and create confusion for the user.

Example
Following code shows how to create groups in the UltraGrid. It creates two groups in the first band.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button28_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button28.Click

      ' Get the band to have the groups in.
      Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)

      Dim group1 As UltraGridGroup = Nothing
      Dim group2 As UltraGridGroup = Nothing

      ' Clear existing groups if any.
      band.Groups.Clear()

      ' Add two groups with two different keys. First arguement to the Add call is
      ' the key and the second arguement is the caption of the group.
      group1 = band.Groups.Add("Group1", "Address Info")
      group2 = band.Groups.Add("Group2", "Contact Info")

      ' If you don't want group headers displayed, set this to false. By default 
      ' it's true.
      band.GroupHeadersVisible = False

      ' Set the LevelCount to desired number of levels. Level 0 is the first row in
      ' the group, while level 1 is the second row in the group and so on. Here we 
      ' are going to have 2 levels.
      band.LevelCount = 2

      ' Add ContactName column to the first level (level 0) of group1 with visible 
      ' position of 0 (meaning it will appear first in that level. There is only 
      ' one header in this particular level level anyways.)
      group1.Columns.Add(band.Columns("ContactName"), 0, 0)

      ' Add City column to second level (level 1) with visible position of 0. And 
      ' also add the Country column to the same level with the visible position of 
      ' 1 so that it appears after City column.
      group1.Columns.Add(band.Columns("City"), 0, 1)
      group1.Columns.Add(band.Columns("Country"), 1, 1)

      ' Add Fax and Phone columns to group2 on different levels.
      group2.Columns.Add(band.Columns("Fax"), 0, 0)
      group2.Columns.Add(band.Columns("Phone"), 0, 1)

      ' Prevet the users from moving groups and columns by setting AllowGroupMoving 
      ' and AllowColMoving to NotAllowed.
      band.Override.AllowGroupMoving = AllowGroupMoving.NotAllowed
      band.Override.AllowColMoving = AllowColMoving.NotAllowed

      ' One could change the various properties like RowSpacingAfter and 
      ' BorderStyleRow on the Override change the appearance.
      band.Override.RowSpacingAfter = 5
      band.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Raised

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void button28_Click(object sender, System.EventArgs e)
{

	// Get the band to have the groups in.
	UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
	 
	UltraGridGroup group1 = null;
	UltraGridGroup group2 = null;
	 		
	// Clear existing groups if any.
	band.Groups.Clear( );
	 	
	// Add two groups with two different keys. First arguement to the Add call is
	// the key and the second arguement is the caption of the group.
	group1 = band.Groups.Add( "Group1", "Address Info" );
	group2 = band.Groups.Add( "Group2", "Contact Info" );
	 
	// If you don't want group headers displayed, set this to false. By default 
	// it's true.
	band.GroupHeadersVisible = false;
	 
	// Set the LevelCount to desired number of levels. Level 0 is the first row in
	// the group, while level 1 is the second row in the group and so on. Here we 
	// are going to have 2 levels.
	band.LevelCount = 2;
	 
	// Add ContactName column to the first level (level 0) of group1 with visible 
	// position of 0 (meaning it will appear first in that level. There is only 
	// one header in this particular level level anyways.)
	group1.Columns.Add( band.Columns["ContactName"],   0,   0 );
	 
	// Add City column to second level (level 1) with visible position of 0. And 
	// also add the Country column to the same level with the visible position of 
	// 1 so that it appears after City column.
	group1.Columns.Add( band.Columns["City"],          0,   1 );
	group1.Columns.Add( band.Columns["Country"],       1,   1 );
	 
	// Add Fax and Phone columns to group2 on different levels.
	group2.Columns.Add( band.Columns["Fax"],		   0,   0 );
	group2.Columns.Add( band.Columns["Phone"],		   0,   1 );

	// Prevet the users from moving groups and columns by setting AllowGroupMoving 
	// and AllowColMoving to NotAllowed.
	band.Override.AllowGroupMoving = AllowGroupMoving.NotAllowed;
	band.Override.AllowColMoving   = AllowColMoving.NotAllowed;
	 
	// One could change the various properties like RowSpacingAfter and 
	// BorderStyleRow on the Override change the appearance.
	band.Override.RowSpacingAfter = 5;
	band.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Raised;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also