Version

CollapseAll Method (UltraGridRow)

Collapses every row in the band and discards all of the expand/collapse information for the child rows.
Syntax
'Declaration
 
Public Sub CollapseAll() 
public void CollapseAll()
Remarks

The CollapseAll method collapses the child rows of a band and discards any information about which children were themselves expanded.

When you invoke the CollapseAll method, the control fires the BeforeRowCollapsed event for every row in the band. In that event, you have the opportunity to cancel the collapse of any row. For all rows except those for which the event was cancelled, the control then collapses the row and any of its children. If those children have children, they are also collapsed, 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.

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