Hello, I am trying to sum a few different columns. Below is the code I am using. I got it working, but I cant seem to find the correct code to format the summary row. I want certain columns to be a number format, and the other ones to be currency.
private void UltraGridUMAFees_InitializeLayout(object sender, InitializeLayoutEventArgs e) { this.UltraGridUMAFees.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.UltraGridUMAFees.DisplayLayout.Bands[0].Columns["Accounts"]); this.UltraGridUMAFees.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.UltraGridUMAFees.DisplayLayout.Bands[0].Columns["FeeReceived"]); this.UltraGridUMAFees.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.UltraGridUMAFees.DisplayLayout.Bands[0].Columns["FeeExpected"]); this.UltraGridUMAFees.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.UltraGridUMAFees.DisplayLayout.Bands[0].Columns["MarketValue"]);
}
Thanks!
Hello IT,
Each time you add a Summary to a grid band the method returns SummarySettings object. To set the formatting of the summary you need to set DisplayFormat property of the returned SummarySttings. You can use code like this:
var accountsSummarySettings = this.UltraGridUMAFees.DisplayLayout.Bands[0].Summaries.Add( SummaryType.Sum, this.UltraGridUMAFees.DisplayLayout.Bands[0].Columns["Accounts"]);accountsSummarySettings.DisplayFormat = "{0:C}";
Additional information about SummarySettings.DisplayFormat you may find in our online documentation here.
Please let me know if you have any additional questions on this matter.
Hello,
Thanks for the answer.
That works, but I also found out this to work also.
private void UltraGridUMAFees_InitializeLayout(object sender, InitializeLayoutEventArgs e) { UltraGridBand gridBand = this.UltraGridUMAFees.DisplayLayout.Bands[0];
(gridBand.Summaries.Add(SummaryType.Sum, gridBand.Columns["Accounts"])).DisplayFormat = "{0:###,###,###}"; (gridBand.Summaries.Add(SummaryType.Sum, gridBand.Columns["FeeReceived"])).DisplayFormat = "{0:$###,###,###}"; (gridBand.Summaries.Add(SummaryType.Sum, gridBand.Columns["FeeExpected"])).DisplayFormat = "{0:$###,###,###}"; (gridBand.Summaries.Add(SummaryType.Sum, gridBand.Columns["MarketValue"])).DisplayFormat = "{0:$###,###,###}";