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:
-
Obtain a reference to a GridControl object.
-
Subscribe to the GroupAdded event of the GridControl object using the GroupAddedEventHandler delegate class
-
Create a new method that will handle the events that are raised. For the purposes of this example, we will call the method grid_GroupAdded.
-
Place the desired code in the newly created event handler.
Basic steps - VB.NET
To subscribe to the GroupAdded event, the following steps must be performed:
-
Obtain a reference to a GridControl object .
-
Subscribe to the GroupAdded event of the GridControl object using the AddHandler/AddressOf keywords.
-
Create a new method that will handle the events that are raised. For the purposes of this example, we will call the method grid_GroupAdded.
-
Place the desired code in the newly added event handler.
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 ); |