Xceed Grid for WinForms v4.3 Documentation
GroupAdded Event

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Events > GroupAdded Event

The GroupAdded event is raised when a group has been added to the grid to allow manipulation of a new group once it has been created.  

Basic steps - C#

To subscribe to the GroupAdded event, the following steps must be performed:

Basic steps - VB.NET

To subscribe to the GroupAdded event, the following steps must be performed:

Demonstration

This example assumes that you are in a Windows application.

VB.NET Copy Code

Imports Xceed.Grid 
AddHandler gridControl1.GroupAdded, AddressOf Me.grid_GroupAdded

' This method will handle the GroupAdded events that are raised.
Private Sub grid_GroupAdded( ByVal sender As Object, _
                             ByVal e As GroupAddedEventArgs)                               
    Try
       e.Group.FooterRows.Add( New TextRow( "This group contains " + _
                                            e.Group.GetSortedDataRowCount().ToString() + _
                                           " rows." ) )
   Catch exception As Exception
       MessageBox.Show( exception.ToString() )
   End Try
End Sub

' If you no longer wish to handle the GroupAdded events that are raised,
' you can unsubscribe from the event notification by doing the following:
RemoveHandler grid.GroupAdded, AddressOf Me.grid_GroupAdded

C# Copy Code
using Xceed.Grid; 
gridControl1.GroupAdded += new GroupAddedEventHandler( grid_GroupAdded ); 
// This method will handle the GroupAdded events that are raised.
private void grid_GroupAdded( object sender, GroupAddedEventArgs e )
{
   try
   {
       e.Group.FooterRows.Add( new TextRow( "This group contains " + _
                                            e.Group.GetSortedDataRowCount().ToString() + _
                                           " rows." ) );
   }
   catch( Exception exception )
   {
       MessageBox.Show( exception.ToString() );
   }
}
// If you no longer wish to handle the GroupAdded events that are raised,
//you can unsubscribe from the event notification by doing the following: 
gridControl1.GroupAdded -= new GroupAddedEventHandler( grid_GroupAdded );