What's the best way of doing this. We'd like to provide a bit of a visual cue to the user when all the groups are collapsed, as it's a bit visually unappealing by default.
I'd like to be able to specify a different colour at the "Type" level to provide a better visual cue of the hierarchy
Hello,
I will be happy to assist you with you question.
I recommend using the InitializeRow event to change the row color for specific bands. To help demonstrate this, I have attached a sample and the code snippet found below:
void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Band.Index == 0) { e.Row.Appearance.BackColor = Color.Blue; } else { e.Row.Appearance.BackColor = Color.Red; } }
Please let me know if you have any questions.
Hi,
My grid doesn't have multiple bands though, it has a single band and a group by box. When they group by the first column I'd like the group's header rows to be one colour, then when they add another column that group should be a different colour (or different shade at least - the 60s are long gone ;-) )
Yes, an exception - typo. Basically, if I set the Appearance.BackColor property of the row referenced by the event, I got an exception. Seems to have gone away with a full rebuild though, so not to worry
Still not sure to determine what my grouping level is though. Ie, in the screenshot at the start of the thread there are two levels of grouping. For a given GroupBy row, how can I tell which level it belongs to?
GroupByRowLevel property on the row looks to be exactly what is needed. Only problem is that it's declared as Friend, so I can't access it :-(
If you want to determine the depth (level) of the GroupByRow, then this is pretty easy. You just walk up the parent chain (ParentRow property) and count the parents.
private int GetRowDepth(UltraGridRow row) { int depth = 0; while(row.ParentRow != null) { row = row.ParentRow; depth++; } return depth; }
Yes, found a thread describing exactly that, and implemented it as an extension method. Given the original property exists, It seems a strange property to hide though?
Please let me know if you have additional question regarding Mike's solution.