Home › Forums › WinForms controls › Xceed Grid for WinForms › Grouping columns limit
I would like to set the limit for grouping columns. Limit to maximum of two grouping columns.
Have you any idea? Or how can I forbid grouping?
Imported from legacy forums. Posted by gony (had 512 views)
You can’t limit the number of columns that can be grouped by setting a maximum. However, you can set a specific column CanBeGrouped property to false, so it cannot be added to the GroupByRow.
gridControl1.Columns[ 0 ].CanBeGrouped =
So I would suggest you change it at runtime. You can do something like the following :
private void Form1_Load(object sender, System.EventArgs e)
new EventHandler( gridControl1_GroupingUpdated );
void gridControl1_GroupingUpdated( object sender, EventArgs e )
//if there is a group
if( gridControl1.Groups.Count > 0 )
//verify if there is another level of groups
if( gridControl1.Groups[ 0 ].Groups.Count > 0 )
//if so, it means 2 columns have been grouped in the GroupByRow
string firstLevelGroup = gridControl1.Groups[ 0 ].GroupBy;
string secondLevelGroup = gridControl1.Groups[ 0 ].Groups[ 0 ].GroupBy;
//so set the columns CanBeGrouped property so no more columns can be added to the GroupByRow
foreach( Column col in gridControl1.Columns )
if( col.FieldName != firstLevelGroup && col.FieldName != secondLevelGroup )
//if not, we make sure any column can be dragged in the GroupByRow
Imported from legacy forums. Posted by André (had 791 views)