Version

BeforeRowCollapsed Event

Occurs before a row is collapsed.
Syntax
'Declaration
 
Public Event BeforeRowCollapsed As CancelableRowEventHandler
public event CancelableRowEventHandler BeforeRowCollapsed
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 collapse. 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 collapsing. This argument can be used to prevent the user from collapsing a row unless a certain condition is met.

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

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

The BeforeRowExpanded and AfterRowExpanded events are generated before and after, respectively, a collapsed row has been expanded.

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

Example
Following code shows some of the information available in BeforeRowCollapsed and how the event could be used.

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_BeforeRowCollapsed(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles ultraGrid1.BeforeRowCollapsed

      ' BeforeRowCollapsed gets fired when the user clicks on the expansion indicator to
      ' collase an expanded row.

      ' This will prevent the user from collapsing any rows in the 1st band.
      If e.Row.Band Is Me.ultraGrid1.DisplayLayout.Bands(0) Then
          Dim preventRowCollapse As Boolean = False

          ' Conditionally prevent rows from band 0 to collapse.
          If preventRowCollapse Then
              e.Cancel = True
          End If
      End If

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

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

	// BeforeRowCollapsed gets fired when the user clicks on the expansion indicator to
	// collase an expanded row.

	// This will prevent the user from collapsing any rows in the 1st band.
	if ( e.Row.Band == this.ultraGrid1.DisplayLayout.Bands[0] )
	{
		bool preventRowCollapse = false;

		// Conditionally prevent rows from band 0 to collapse.
		if ( preventRowCollapse )
			e.Cancel = true;
	}

}
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