Home Forums WinForms controls Xceed Grid for WinForms Group Sort/ Order Reply To: Group Sort/ Order

Xceed Support
Member
Post count: 5658

You could use the <a href=”http://doc.xceedsoft.com/products/Xceedgrid/Custom_Sorting.html”&gt; custom sorting</a> to pre-decide which group is going to be on top by explicitly calling a sort on the specific column and preventing the user from re-sorting after.

The following code will always show the group with the “2” value on top and the “3” value at the bottom:

<code>
for( int j = 0; j < 4; j++ )
{
Column col = new Column( “Column”+j.ToString(), typeof(int) );
gridControl1.Columns.Add( col );
}

gridControl1.Columns[ 0 ].DataComparer = new SpecialComparer();

for( int i = 0; i < 20; i++ )
{
Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
foreach( Cell cell in row.Cells )
{
cell.Value = i % 5;
}
row.EndEdit();
}

Group group = new Group( “Column0” );
gridControl1.GroupTemplates.Add( group );
gridControl1.Columns[ 0 ].SortDirection = SortDirection.Ascending;

gridControl1.UpdateGrouping();
( ( ColumnManagerRow )gridControl1.FixedHeaderRows[ 1 ] ).AllowSort = false;
( ( GroupByRow )gridControl1.FixedHeaderRows[ 0 ] ).AllowGroupingModification = false;
</code>

Imported from legacy forums. Posted by CharlesB (had 513 views)