Infragistics(R) NetAdvantage(R) Windows Forms
ExpandAll Method
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridRow Class : ExpandAll Method

Expands all rows (and bands, if applicable) in the object. Ignores the existing expanded/collapsed state of any rows or bands.

Syntax

Visual Basic (Declaration) 
Public Sub ExpandAll() 
C# 
public void ExpandAll()

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.

Visual BasicCopy Code
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
C#Copy Code
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( );
	}

}

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 Infragistics.Win.UltraWinGrid.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.

See Also