Defining custom grouping in XCEED Grid .NET

Hi all,

you all folks who had to deal to XCEED Grid know that a grouping feature through "GroupTemplates" is quite powerful in that grid control. What really bothers is actually quite confusing group titles nomination which Grid automaticaly produces (ie. "myField - someValue - XY items"). Since "MyField" - the database field name - can be something like "ABC200R1", and values could be actually IDs (ie. combo boxes in grid), that is not very helpfull for the user.

Well, what I needed to do, is to group data in the grid, and that it is visualy very well divided (huge group headers), and group titles which make sense- not the default ones, but values read from another DataTable object.

//add group
Group grPriRas = new Group("myField");

//make group readonly - that the user cannot remove it 
grPriRas.ReadOnly =

//some visual adjustments 
grPriRas.VerticalAlignment = VerticalAlignment.Center;
grPriRas.HeaderRows[0].Height = 32;
grPriRas.HeaderRows[0].Font =
new Font("Tahoma", 16, FontStyle.Bold);
grPriRas.HeaderRows[0].ForeColor = Color.Crimson;
grPriRas.HeaderRows[0].BackColor = Color.WhiteSmoke;

//cast it to the GroupManagerRow, so we can change title properties
GroupManagerRow gmr = (GroupManagerRow) (grPriRas.HeaderRows[0]);

//set the title format - will be needed for creating custom titles
gmr.TitleFormat = "%GroupTitle% - %DataRowCount% items";

//add and update group

//now, iterate through just created groups and change titles,  
foreach (Group grp in GridControl.Groups) grp.Title = dtAnotherTable.Select("TableID='" + grp.Key + "'")[0]["DESCRIPTION"].ToString();


This article considers only XCEED Grid .NET, not XCEED Grid for WPF!


Published Wednesday, September 26, 2007 4:05 PM by Adis Jugo
Filed under: , ,