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
85
Change text in Summary Row cell dynamically
posted

I am adding a summary to my grid using:

Dim summary = DataGrid.DisplayLayout.Bands(2).Summaries.Add(SummaryType.Sum, DataGrid.Layout.Bands(2).Columns(3))

summary.DisplayFormat = "{0:#,##0.00}" (this removes the "Sum=" and formats the number displayed)

I also have another summary cell added as a "Summary Title" using:

summary = DataGrid.DisplayLayout.Bands(2).Summaries.Add(String.Empty, Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn, DataGrid.DisplayLayout.Bands(2).Columns(2))

summary.DisplayFormat = "Total For Currency"

My question is, is there any way to change the "Total For Currency" text when the form is loaded to display the currency code for that particular band ie "Total for GBP" if the currency code is GBP etc

I have tried looping through each row when the parent row is expanded and changing the displaylayout for the summary, but in cases where I have 2 rows in the same band with different currency codes, the previous "Total for " will get overwritten and both will display the value for the second row. eg if the first row in the band has currency code of EUR and second has code of GBP, both summary texts will show "Total For GBP"

  • 469350
    Verified Answer
    Offline posted

    Hi Patels,

    I'm having some trouble understanding your question.

    It sounds like your Sum summary needs to have a different label based on the child band it's in. Is that right?

    The DisplayFormat for the summary is on the SummarySettings, which applies to the entire band. So you can't change the format for one set of rows in the band and not for another.

    There are a couple of approaches you could take to achieve what you want. One would be to use a CreationFilter or DrawFilter. This approach has a down side, which is that auto-sizing the columns won't be able to properly account for the summary text. But the advantage is that this approach will work in older versions of the grid.

    Another option (which I like better) would be to use an external summary. This would allow you to use the summary Value as the text and you can assign any arbitrary text to the summary value instead of using a format. This approach will be better for auto-sizing, but it will only work in a recent version of the grid, since external summaries were only added recently.

    Both approaches depend greatly on the criteria you are using to determine the summary title text. And since I'm not clear on what your criteria is, it's tough for me to provide you with sample code. I've attached a small sample here which determines which caption to show based on the parent row that contains the summary value.

    WindowsApplication2.zip