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
AD
Administrator
Syncfusion Team
May 10, 2006 03:32 AM UTC
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
AD
Administrator
Syncfusion Team
May 10, 2006 06:12 PM UTC
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
AD
Administrator
Syncfusion Team
May 10, 2006 06:26 PM UTC
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
AD
Administrator
Syncfusion Team
May 11, 2006 05:07 AM UTC
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
AD
Administrator
Syncfusion Team
May 11, 2006 02:29 PM UTC
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?
AD
Administrator
Syncfusion Team
May 12, 2006 06:07 AM UTC
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