We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to format summary field?

Thread ID:





43961 May 9,2006 03:59 PM May 12,2006 02:07 AM Windows Forms 6
Tags: GridControl
Administrator [Syncfusion]
Asked On May 9, 2006 03:59 PM

Hi, I''m using GGC and also I have a summary row with a field, where GridSummaryColumnDescriptor.Format = "{Sum}"; GridSummaryColumnDescriptor.SummaryType = Syncfusion.Grouping.SummaryType.DoubleAggregate; The data in the column is decimal. The summary row works fine, but I''m having trouble in setting the formating of this filed to currency. I tried 2 things: 1)GridSummaryColumnDescriptor.Appearance.SummaryFieldCell.Format="c" 2) in Grid_QueryCellStyleInfo: if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell) { int i = e.TableCellIdentity.Table.TableDescriptor.ColIndexToField(e.TableCellIdentity.ColIndex); GridVisibleColumnDescriptor fd=e.TableCellIdentity.Table.TableDescriptor.VisibleColumns[i]; e.Style.Format="c"; } None of the methods work. Please advise. Thank you

Administrator [Syncfusion]
Replied On May 9, 2006 11:32 PM

Hi, The format string used to format the text to display in the summary column. A format string consists of the PropertyName of the summaryType and a format specifier known from String.Format, e.g. {Average:###.00}. Colud you try this code GridSummaryColumnDescriptor.Format = "{Sum: $#,##.00}"; Please let me know if this helps. Best Regards, Haneef

Administrator [Syncfusion]
Replied On May 10, 2006 02:12 PM

Thank for the response. But if I set e.Style.Format="{Sum: $#,##.00}"; in QueryCellStyleInfo eventhandler - the formatting does not work. Besides in my case I need to set formatting to the {0:c} equivalent, cince the currency can be not only US. Please advise Thank you

Administrator [Syncfusion]
Replied On May 10, 2006 02:26 PM

Actually setting GridSummaryColumnDescriptor.Format = "{Sum:c}"; - works!!! But changing e.Style.CultureInfo does not produce affect anything. The culture is still a default(US) culture. What needs to be done to change the formatting culture dynamically? Thank you

Administrator [Syncfusion]
Replied On May 11, 2006 01:07 AM

Hi, You need to set the CurrentThread''s CultureInfo in form''s constructor.Here is a code snippet. CultureInfo c = new CultureInfo("he-IL"); System.Threading.Thread.CurrentThread.CurrentCulture = c; Please refer to the attached sample for more details. http://www.syncfusion.com/Support/user/uploads/DefiningSummaries_CS_2c1a2aa.zip Let us know if you need any further help. Regards, Haneef

Administrator [Syncfusion]
Replied On May 11, 2006 10:29 AM

Thank you. This definetely works, but not in my case. I have multiple currencies displayed on the form and setting Thread''s culture will break my logic. Is there any other workaround?

Administrator [Syncfusion]
Replied On May 12, 2006 02:07 AM

Hi , For particular Summary cellvalue, you have to set explicitly the value whatever you want to see. Here is a code snippet. //SummaryCell description in a grid. GridSummaryColumnDescriptor sd = new GridSummaryColumnDescriptor(); sd.DataMember= "Col2"; sd.DisplayColumn = "Col2"; sd.Format = "{Sum}"; sd.SummaryType = SummaryType.DoubleAggregate; //Adding SummaryCell in a grid. this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Col2", "Sum", sd)); //QueryCellStyleInfo Event. if(e.TableCellIdentity.TableCellType==GridTableCellType.SummaryFieldCell) { double val; e.Style.CultureInfo = new System.Globalization.CultureInfo("he-IL"); Double.TryParse((string)e.Style.CellValue, NumberStyles.AllowDecimalPoint, e.Style.CultureInfo, out val); e.Style.Text = string.Format(e.Style.CultureInfo,"{0:c}", val);; } For more details, See the attached sample. http://www.syncfusion.com/Support/user/uploads/DefiningSummaries_CS_71e93bb9.zip Please let me know if this helps. Best Regards, Haneef


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.