Version

ExpandAll Method (UltraGridRow)

Expands all rows (and bands, if applicable) in the object. Ignores the existing expanded/collapsed state of any rows or bands.
Syntax
'Declaration
 
Public Sub ExpandAll() 
public void ExpandAll()
Remarks

The ExpandAll method expands all the child rows of a band. If those rows have any children, they are also expanded, and so on until the bottom level of the hierarchy is reached.

When you invoke the ExpandAll method, the control fires the BeforeRowExpanded event for every row in the band. In that event, you have the opportunity to cancel the expansion of any row. For all rows except those for which the event was cancelled, the control then expands the row and any of its children. If those children have children, they are also expanded, and so on down to the bottom level of the hierarchy. Any context information that was previously accumulated as the result of the user expanding and collapsing child rows is discarded.

The Expanded property can be used to expand or collapse a row without expanding its descendants.

The RowsCollection.ExpandAll method which takes in a recursive paramater can be used to expand only the immediate children of the rows collecition or all the descendants depending on the value of the recursive paramter.

The CollapseAll method can be invoked to collapse all descendent rows.

Example
Following code illustrates how ExpandAll and CollapseAll methods off the UltraGridRow work. It expands and collapses the active row (or the first row if there is no active row) on successive button clicks.

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

  Private toggleFlag As Boolean = False

  Private Sub Button109_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button109.Click

      Dim row As UltraGridRow = Me.UltraGrid1.ActiveRow

      ' If there is no active row, then use the first row.
      If row Is Nothing Then
          row = Me.ultraGrid1.Rows(0)
      End If

      ' Toggle the flag.
      Me.toggleFlag = Not Me.toggleFlag

      If Me.toggleFlag Then
          ' Call ExpandAll to expand the row and it's descendant rows recursively.
          row.ExpandAll()
      Else
          ' Call CollapseAll to collapse the row and it's descendant rows recursively.
          row.CollapseAll()
      End If

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

private bool toggleFlag = false;

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

	UltraGridRow row = this.ultraGrid1.ActiveRow;

	// If there is no active row, then use the first row.
	if ( null == row )
		row = this.ultraGrid1.Rows[0];

	// Toggle the flag.
	this.toggleFlag = !this.toggleFlag;

	if ( this.toggleFlag )
	{
		// Call ExpandAll to expand the row and it's descendant rows recursively.
		row.ExpandAll( );
	}
	else
	{
		// Call CollapseAll to collapse the row and it's descendant rows recursively.
		row.CollapseAll( );
	}

}
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