Skip to content

Get summary value from a grid

New Discussion
Andrea Mariotti
Andrea Mariotti asked on May 2, 2016 5:06 PM

Good afternoon,

I create some summary with this code:

column = e.Layout.Bands[2].Columns[“ColumnName”];

column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Currency;

ss = column.Band.Summaries.Add(SummaryType.Sum, column);

ss.DisplayFormat = “{0:N2}”;

How can I read the value of that Summary?

I tried to reach it with:

gridName.DisplayLayout.Bands[2].Summaries[“ColumnName”]

But there’s no “value” or “text” property that I can read.

Thanks in advance

Sign In to post a reply

Replies

  • 0
    Sahaja Kokkalagadda
    Sahaja Kokkalagadda answered on Apr 22, 2016 9:45 PM

    Hi Andrea,

    You cannot use band to get summary value, you have get it from Rows Collection. For the root band you can get it by doing something like this

    this.ultraGrid1.Rows.SummaryValues[SummarySettings].Value

    There’s no way to get a summary for a child band, because there are no summaries for child bands. Once again, the summary is a summary of a rows collection. So if you want to get summary value for a child band rows collection then you would have to get reference of that particular rows collection and use SummaryValues collection on that.

    Please let me know if you have any questions.

    Sincerely,
    Sahaja Kokkalagadda
    Associate Software Developer, Windows Forms

    • 0
      Andrea Mariotti
      Andrea Mariotti answered on Apr 27, 2016 10:07 AM

      Goodmorning,

      sorry but I don't understand:

      I've got a master-detail, each master record has 2 detail table and each detail table has got a summary like the way I posted before:

      column = e.Layout.Bands[2].Columns["ColumnName"];

      column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Currency;

      ss = column.Band.Summaries.Add(SummaryType.Sum, column);

      ss.DisplayFormat = "{0:N2}";


      If I use your code:

      this.ultraGrid1.Rows.SummaryValues[SummarySettings].Value


      the this.ultraGrid1.Rows.SummaryValues is empty.


      If I've got a summary in the band[1] or band[2] how can I read it?

      • 0
        Sahaja Kokkalagadda
        Sahaja Kokkalagadda answered on May 1, 2016 3:08 PM

        Hi Andrea,

        In InitializeRow event you can check for e.Row.Band.Key or e.Row.Band.Index and if it is the band you are interested in then get the summary values of that bands rows collection. For example you can do something like this
        e.Row.Bands[1].Rows.SummaryValues[” “].Value

        Please try this and let me know if you need any further assistance.

        Sincerely,
        Sahaja Kokkalagadda
        Associate Software Developer, Windows Forms

      • 0
        Mike Saltzman
        Mike Saltzman answered on May 2, 2016 3:27 PM

        To get a child rows collection under a parent row, you do something like this:

        this.ultraGrid1.Rows[rowIndex].ChildBands[bandIndex/bandKey].Rows

        Once you have the rows collection, you can access the SummaryValues just like you do with the root-level rows:

        this.ultraGrid1.Rows[rowIndex].ChildBands[bandIndex/bandKey].Rows.SummaryValues[summaryIndex/summaryKey].Value

      • 0
        Andrea Mariotti
        Andrea Mariotti answered on May 2, 2016 5:06 PM

        Goodafternoon Mike,

        this works very well, thanks for all!

        Also using the Sahaja's solution (with the ParentCollection idea that I posted before) works really well.

      • 0
        Andrea Mariotti
        Andrea Mariotti answered on May 2, 2016 5:05 PM

        Hi Sahaja,

        this code doesnt work cause the e.Row doesn't have a "Bands" collection property (it has only a "Row" property).

        But you bring me an idea: 

        e.Row.ParentCollection can work with the SummaryValues!

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Andrea Mariotti
Favorites
0
Replies
6
Created On
May 02, 2016
Last Post
10 years, 5 months ago

Suggested Discussions

Created by

Created on

May 2, 2016 5:06 PM

Last activity on

Feb 23, 2026 9:57 AM