Version

BeforeRowExpanded Event

Occurs before a row with children is expanded.
Syntax
'Declaration
 
Public Event BeforeRowExpanded As CancelableRowEventHandler
public event CancelableRowEventHandler BeforeRowExpanded
Event Data

The event handler receives an argument of type CancelableRowEventArgs containing data related to this event. The following CancelableRowEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Row The row that the cell belongs to (read-only)
Remarks

The row argument returns a reference to an UltraGridRow object that can be used to set properties of, and invoke methods on, the row that will expand. You can use this reference to access any of the returned row's properties or methods.

The cancel argument enables you to programmatically prevent the row from expanding. This argument can be used to prevent the user from expanding a row unless a certain condition is met.

This event is generated before a row has been expanded, either programmatically, or by user interaction. A row can be expanded programmatically by setting its Expanded property to True.

The expansion (plus/minus) indicators can be hidden for a row to preventthe user from expanding or collapsing it by setting the ExpansionIndicator property.

The BeforeRowCollapsed and AfterRowCollapsed events are generated before and after, respectively, an expanded row has been collapsed.

The AfterRowExpanded event, which occurs after a row has been expanded, is generated after this event, provided cancel is not set to True.

Example
Following code illustrates how one can use BeforeRowExpanded event to have only one expanded row at a time. Every time the user expands a different row, any previously expanded rows will be collapsed.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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

  Private Sub UltraGrid1_BeforeRowExpanded(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles ultraGrid1.BeforeRowExpanded

      ' Before e.Row gets expanded, collapse all the previously expanded rows so we
      ' only have one expanded row.
      e.Row.ParentCollection.CollapseAll(False)

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

private void ultraGrid1_BeforeRowExpanded(object sender, Infragistics.Win.UltraWinGrid.CancelableRowEventArgs e)
{			

	// Before e.Row gets expanded, collapse all the previously expanded rows so we
	// only have one expanded row.
	e.Row.ParentCollection.CollapseAll( false );

}
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