'Declaration <DescriptionAttribute("Raised after a data row has been built in order to group it.")> <CategoryAttribute("Data")> Public Event QueryGroupKeys As QueryGroupKeysEventHandler
'Usage Dim instance As GridControl Dim handler As QueryGroupKeysEventHandler AddHandler instance.QueryGroupKeys, handler
[Description("Raised after a data row has been built in order to group it.")] [Category("Data")] public event QueryGroupKeysEventHandler QueryGroupKeys
Event Data
The event handler receives an argument of type QueryGroupKeysEventArgs containing data related to this event. The following QueryGroupKeysEventArgs properties provide information specific to this event.
Property | Description |
---|---|
DataRow | Gets the data row to group. |
GroupKeys | Gets a list containing the group values. |
Remarks
When creating custom groups, the GroupBy property must be set in order for the groups which are created manually to be sorted. These groups will be sorted in the same direction as the columns whose fieldname is set in the GroupBy property.
Example
The following example will group all the data rows according to the value of the
ShipCountry cell. All data rows whose ShipCountry cell's value begins with A to M
will be grouped together while those from N to Z will be grouped together.
The second group level will regroup all data rows according to the value of the ShipCity
cell. All data rows whose ShipCity cell's value begin with the 2 same letters will
be grouped together. For example, Mannheim and Marseille will be regrouped together.
gridControl1.GroupTemplates.Add( New Group( "ShipCountry" ) ) gridControl1.GroupTemplates.Add( New Group( "ShipCity" ) ) AddHandler gridControl1.QueryGroupKeys, AddressOf Me.grid_QueryGroupKeys ' This method will handle the QueryGroupKeys events that are raised. Private Sub grid_QueryGroupKeys( ByVal sender As Object, ByVal e As QueryGroupKeysEventArgs ) Handles grid.QueryGroupKeys Try Dim countryValue As String = e.DataRow.Cells( "ShipCountry" ).Value.ToString().Substring( 0, 1 ).ToUpper() If( countryValue.CompareTo( "M" ) > 0 ) Then e.GroupKeys( 0 ) = "N-Z" Else e.GroupKeys( 0 ) = "A-M" End If Dim cityValue As String = e.DataRow.Cells( "ShipCity" ).Value.ToString().Substring( 0, 2 ).ToUpper() e.GroupKeys( 1 ) = cityValue Catch exception As Exception MessageBox.Show( exception.ToString() ) End Try End Sub
gridControl1.GroupTemplates.Add( new Group( "ShipCountry" ) ); gridControl1.GroupTemplates.Add( new Group( "ShipCity" ) ); gridControl1.QueryGroupKeys += new QueryGroupKeysEventHandler( this.grid_QueryGroupKeys ); private void grid_QueryGroupKeys( object sender, QueryGroupKeysEventArgs e ) { try { string countryValue = e.DataRow.Cells[ "ShipCountry" ].Value.ToString().Substring( 0, 1 ).ToUpper(); if( countryValue.CompareTo( "M" ) > 0 ) { e.GroupKeys[ 0 ] = "N-Z"; } else { e.GroupKeys[ 0 ] = "A-M"; } string cityValue = e.DataRow.Cells[ "ShipCity" ].Value.ToString().Substring( 0, 2 ).ToUpper(); e.GroupKeys[ 1 ] = cityValue; } catch( Exception exception ) { MessageBox.Show( exception.ToString() ); } }
Requirements
Target Platforms: 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