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

The GroupByRow object corresponds to a GroupBy Row displayed in the grid.

Syntax

Visual Basic (Declaration) 
Public NotInheritable Class UltraGridGroupByRow 
   Inherits UltraGridSpecialRowBase
   Implements Infragistics.Shared.ISelectableItem, Infragistics.Shared.ISparseArrayItem, Infragistics.Shared.ISparseArrayMultiItem, Infragistics.Win.IUIElementProvider, Infragistics.Win.IUIElementTextProvider 
C# 
public sealed class UltraGridGroupByRow : UltraGridSpecialRowBase, Infragistics.Shared.ISelectableItem, Infragistics.Shared.ISparseArrayItem, Infragistics.Shared.ISparseArrayMultiItem, Infragistics.Win.IUIElementProvider, Infragistics.Win.IUIElementTextProvider  

Example

Following code shows some of the information available in InitializeGroupByRow event and its potential uses. It sets the appearance of the group-by rows based on number of items they contain.

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.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_InitializeGroupByRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs) Handles ultraGrid1.InitializeGroupByRow

       ' ReInitialize indicates whether the row is being initialized for the first time
       ' or it's being re-initialized.
       If e.ReInitialize Then
           Debug.WriteLine("A group-by row is being re-initilaized.")
       Else
           Debug.WriteLine("A group-by row is being initilaized.")
       End If

       ' Set the description to desired value. This is the text that shows up on
       ' the group-by row.
       e.Row.Description = e.Row.Value.ToString() & ", " & e.Row.Rows.Count & " Items."

       ' We only want to do this if we are grouping by the Country column.
       If e.Row.Column.Key = "Country" Then
           ' If the group has more than 5 items, then make the background color 
           ' of the row to red
           If e.Row.Rows.Count > 5 Then
               e.Row.Appearance.BackColor = Color.Red
           Else
               e.Row.Appearance.ResetBackColor()
           End If
       End If

   End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_InitializeGroupByRow(object sender, Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs e)
{

	// ReInitialize indicates whether the row is being initialized for the first time
	// or it's being re-initialized.
	if ( e.ReInitialize )
		Debug.WriteLine( "A group-by row is being re-initilaized." );
	else
		Debug.WriteLine( "A group-by row is being initilaized." );

	// Set the description to desired value. This is the text that shows up on
	// the group-by row.
	e.Row.Description = e.Row.Value.ToString( ) + ", " + e.Row.Rows.Count + " Items.";

	// We only want to do this if we are grouping by the Country column.
	if ( e.Row.Column.Key == "Country" )
	{
		// If the group has more than 5 items, then make the background color 
		// of the row to red
		if ( e.Row.Rows.Count > 5 )
		{
			e.Row.Appearance.BackColor = Color.Red;
		}
		else
		{
			e.Row.Appearance.ResetBackColor( );
		}
	}

}

Remarks

The GroupBy Row appears in a Band of the grid that has been placed in GroupBy mode and has had at least one field specified for grouping data. GroupBy Rows are similar to regular grid Rows except that they do not display data from multiple fields. Instead, they serve to visually separate rows of data according to the grouping to which they belong. A GroupBy Row displays only the data value from the filed or fields being used to group the data.

For example, if you have a Band that contains address data and you use GroupBy mode to group the data according to the value of the City field, You will see the a GroupBy Row appear for every city that appears in the data; the GroupBy Row displays just the name of each city. Following each GroupBy Row will be all the data records contain the same value for the City field as that displayed in the GroupBy Row.

GroupBy Rows can be expanded or collapsed to display or hide the rows corresponding to a particular value. The GroupBy Row also contains the user interface elements needed to expand and collapse rows. Programmatically, you can use this object to find out information about the state of the row grouping, such as whether the grouping can be expanded and how many rows are grouped under the GroupBy Row.

See Also