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
300
Draw column borders in GroupByRows
posted

I've seen similar threads, but not this exact problem. I'm trying to draw the column borders in my GroupByRows so they look like data rows in the grid. 

I'm using the SummaryCells display style to align Summaries with Columns. 

this.DisplayLayout.Override.GroupBySummaryDisplayStyle = Infragistics.Win.UltraWinGrid.GroupBySummaryDisplayStyle.SummaryCells;

For columns with summaries this works great and I can easily draw borders using the DrawFilter. The problem is for columns that don't have summaries.

My current approach is to use a DrawFilter to draw a line from the Header all the way across the grid. I'm using the AfterDrawForegroundPhase for the HeaderUIElement, but my lines seem to be getting drawn over by the body of the grid. (See code and screen shot below. Lines are in red, blue rows are GroupByRows).

Is there a better phase/UIElement to use? A different approach altogether? My other thought is to attach a custom summary to all columns that does nothing, just so I can draw its borders. That seems like a waste though.

Thanks,
Stefan

In GetPhasesToFilter:

else if (drawParams.Element is HeaderUIElement)
                return DrawPhase.AfterDrawForeground;

 

In DrawElement

else if (drawParams.Element is HeaderUIElement)
            {
               int gridBottom = drawParams.Element.ControlElement.RectInsideBorders.Bottom;

                // Draw column borders through the entire grid
 drawParams.Graphics.DrawLine(System.Drawing.Pens.Red, new Point(drawParams.Element.RectInsideBorders.X - 2, drawParams.Element.Rect.Y),
new Point(drawParams.Element.RectInsideBorders.X - 2, gridBottom));
            }

 

 

 

Parents
  • 469350
    Offline posted

    Hi Stefan,

    I'm not sure I understand the issue. What do you mean by this? 

    sdsain said:
    my lines seem to be getting drawn over by the body of the grid.

    I don't see any lines across the body of the grid. All I see are lines in the header. Isn't drawing lines across the body of the grid what you want to happen? Did you mean to say that your lines are NOT getting drawn across the body of the grid?

    Personally, I'd just add a summary to each column. That would be a lot easier.


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridOverride ov = layout.Override;
                UltraGridBand band = layout.Bands[0];

                layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
                band.SortedColumns.Add("Int32 1", false, true);

                ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows;
                ov.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells;
                ov.GroupBySummaryValueAppearance.BorderColor = Color.Black;

                BlankSummaryCalculator blankSummaryCalculator = new BlankSummaryCalculator();

                foreach (UltraGridColumn column in band.Columns)
                {
                    SummarySettings summarySettings = band.Summaries.Add(SummaryType.Custom, blankSummaryCalculator, column, SummaryPosition.UseSummaryPositionColumn, column);
                    summarySettings.DisplayFormat = "{0}";
                }
            }


        public class BlankSummaryCalculator : ICustomSummaryCalculator
    {
        #region ICustomSummaryCalculator Members

        void ICustomSummaryCalculator.AggregateCustomSummary(SummarySettings summarySettings, UltraGridRow row)
        {
           
        }

        void ICustomSummaryCalculator.BeginCustomSummary(SummarySettings summarySettings, RowsCollection rows)
        {
           
        }

        object ICustomSummaryCalculator.EndCustomSummary(SummarySettings summarySettings, RowsCollection rows)
        {
            return null;
        }

        #endregion
    }

     

Reply Children