Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1425
Appearance of Summary Rows and Cells in Grid
posted

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:

  1. Summary values on each GroupBy row.
  2. Summary footer row (and it's Summary values).

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

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Richard,

    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
            }

     

     

     

Children