The GroupBy property and the QueryGroupKeys event can be used together to provide custom grouping criteria. The GroupBy property can be set using either code or the property grid, however custom grouping must be done via code.
C# | Copy Code |
---|---|
|
In order for a group to have an effective visual representation in the grid, it must contain at least one row in either its header or footer rows.
C# | Copy Code |
---|---|
gridControl1.GroupTemplates.Add( group ); //Subscribe to the QueryGroupKeys event. |
It is then necessary to handle the QueryGroupKeys event to determine when a new group is created. For example, the code in the event handler below will group all data rows that have the same value for ShipCountry but in an case insensitive manner. This means that both "Canada" and "canada" will be grouped together.
C# | Copy Code |
---|---|
private void grid_QueryGroupKeys( object sender, QueryGroupKeysEventArgs e ) |