I am utilizing the EnableSumary for a wingrid.. I have formatted several of the columns.. but when i use the summary tool.. i don't get those formats applied.. is there a way to do this?
So for example I go through and set a column format like so..
UltraGridcolumn.Format = "#,##0.000";
All of the data is then formatted correctly in the grid.. however, when I click the Summary E in the column Header.. the number listed is not fomatted.. is there a way to format this Summary Number?
It looks like this...
ID Header sum = 706271 2565.0002 2911.0003. 1784.000
etc...
Also the format string is different "{0:#,##0.000}"
Nick
When you create your summary using Summaries.Add, the Add method returns a SummarySettings object.
SummarySettings summarySettings = band.Summaries.Add(...);
summarySettings.DisplayFormat = "{0:#,##0.000}";
You could make this a little more efficient like so:
foreach (SummarySettings summarySettings in e.Column.Band.Summaries) { if (summarySettings.SourceColumn == e.Column) summarySettings.DisplayFormat = summarySettings.SummaryType + "= {0:" + e.Column.Format + "}"; }
This code also assume that Format is not empty. I'm not sure what will happen if the Format is blank.
This will not work as you are assuming that the index of the Summaries matches the Column header value.
This is what I used to make it work:
for (int i = 0; i < e.Column.Band.Summaries.Count; i++){ e.Column.Band.Summaries[ i ].DisplayFormat = e.Column.Band.Summaries[ i ].SummaryType + "= {0:" + e.Column.Band.Summaries[ i ].SourceColumn.Format + "}";}
Its not very good as each time you add/remove any form of summary you end up resetting ALL summaries, but I have not come up with a better version ... yet
tried putting this in the AfterSummaryDialog event wont work [:'(]
e.Column.Band.Summaries[e.Column.Key].DisplayFormat = e.Column.Format;
In that case, you should use the AfterSummaryDialog event, so you set the DisplayFormat once when the summary is created, rather than every time the value changes.
Well the summary is chosen to be used or not by the user at run time therefore I would like it done in an event.