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
1210
Adding a summary row programmatically
posted

The following code works on a single row in the grid called Column 0. If I wanted to add another column to the summary such as Column 1, what do I need to do in the code below?

 

UltraGridBand band = ultraGrid1.DisplayLayout.Bands[0];            

ultraGrid1.DisplayLayout.Bands[0].Columns["Column 0"].AllowRowSummaries = AllowRowSummaries.True;            

 SummarySettings SumSummary = band.Summaries.Add("Sum " + "Column 0", SummaryType.Sum, band.Columns["Column 0"]);            

SumSummary.DisplayFormat = "{0:#,##0.00}";            

SumSummary.Appearance.TextHAlign = HAlign.Right;            

 SumSummary.SummaryDisplayArea |= SummaryDisplayAreas.Bottom;            

//ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.Bottom;            

 band.SummaryFooterCaption = "Subtotal:";            

 band.Override.SummaryFooterCaptionAppearance.FontData.Bold = DefaultableBoolean.True;            

band.Override.SummaryFooterCaptionAppearance.BackColor = Color.LightSteelBlue;            

band.Override.SummaryFooterCaptionAppearance.ForeColor = Color.Black;            

 // Here, I want to add grand total

UltraGridColumn columnToSummarize = band.Layout.Bands[0].Columns["Column 0"];            

SummarySettings summary = band.Layout.Bands[0].Summaries.Add("Grand Total For " + "Column 0", SummaryType.Sum, columnToSummarize);

 summary.DisplayFormat = "{0:#,##0.00}";            

summary.SummaryDisplayArea |= SummaryDisplayAreas.GroupByRowsFooter;            

 summary.Appearance.TextHAlign = HAlign.Right;            

// Disable grid default highlight

ultraGrid1.DisplayLayout.Override.ResetActiveRowAppearance();            

ultraGrid1.DisplayLayout.Override.ResetActiveCellAppearance();            

ultraGrid1.DisplayLayout.Override.ActiveAppearancesEnabled = DefaultableBoolean.False;

Parents
No Data
Reply
  • 1210
    Verified Answer
    posted

    SumSummary = band.Summaries.Add(SummaryType.Sum, band.Columns["Column 1]);

     

    after the line:  SummarySettings SumSummary = band.Summaries.Add("Sum " + "Column 0", SummaryType.Sum, band.Columns["Column 0"]);            

     

    is what works

Children