Hi All,
Does anyone know if it's possible to change the appearance of a summary row in an UltraGrid for a specific group? In the image below (sorry it may not be too easy to see), if the user selects a GroupBy row I'd like them to be able to change the appearance for that group level.
The areas outlined in red are those that I am unsure how to change:
I have found the properties for ammending the default appearance for summaries, but I'm hoping this is possible too...
Any help will be greatly appreciated.
Cheers,
Richard
Thanks for the info, Mike. Here's a screen of what I'm getting so far:
I'd like the summary footer (outlined in red) to adopt the same style as the Group row it is associated with e.g. In this example it would have a gold background, a dark red foreground and also adopt the same bold, italic and font name of the group row. If I were to add another group, this group level could have a different style i.e. the summary footers will be different for each group level.
Hi Richard,
The DrawFilter intercepts the actual drawing of the elements on the screen, so it won't affect the report.
It might be tough to achieve this in the report, because the Documents engine uses a sort've forward-only model.
I'm not sure, though, since I'm not really clear on exactly what you are trying to do. What are you trying to change the font of, exactly?
Hi Mike,
A little follow up question...
Is it possible to do the same when exporting the grid to a report? It appears the draw filter isn't used while exporting the grid, so does that mean this is not possible?
I managed to get it to change the background colour by handling the exporter's SummaryRow Exported event, but the appears to be no properties for ammending the font...
Thanks Mike!! The code was very helpful! I've implemented a similar DrawFilter that simply applies the appearance properties of the group-by row it's associated with, and then apply that filter to the UltraGrid.
Cheers!
Richard said:Summary values on each GroupBy row.
This is pretty easy. What I would do is handle the grid's InitializeGroupByRow event. You can examine the GroupByRow and determine what you want to do and then set the appearance of the SummaryValue on that row.
For example:
private void ultraGrid1_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e) { if ((int)e.Row.Value == 1) e.Row.Rows.SummaryValues[0].Appearance.BackColor = Color.Blue; }
Richard said: Summary footer row (and it's Summary values).
I don't think there is any simple way to do this. The SummaryValue has an object in the grid that represents it, so there's an appearance for each individual summary value. But there is no such object for the Summary footer row, it's the same for the entire grid. The only way to color this area for just a single row would be to use a DrawFilter.
Also, the Summary footer area you highlight here is comprised of multiple UIElements, so you can't do this by filtering on a single UIElement.
The DrawFilter code is actually not too bad, though. Here's some quick code I whipped up:
public class SummaryFooterDrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { RowsCollection rows = drawParams.Element.GetContext(typeof(RowsCollection)) as RowsCollection; if (rows != null) { UltraGridGroupByRow groupbyRow = rows.ParentRow as UltraGridGroupByRow; if (groupbyRow != null && (int)groupbyRow.Value == 1) { drawParams.AppearanceData.BackColor = Color.Red; } } return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is SummaryFooterUIElement || drawParams.Element is SummaryFooterCaptionUIElement) { return DrawPhase.BeforeDrawBackColor; } return DrawPhase.None; } #endregion }