Converter exception in SfDataGrid demo
Hello.
If you try to show the "Conditional Cell Style" example of the WPF SfDataGrid demo, that'll raise an exception in the StyleConverterforQS2 class. That happens because my PC is set for use the euro currency. That is, the value argument is a string terminating with the "€" symbol. That fails the double parsing, hence the exception.
Thanks
Attachment: image_16_8c015503.png
Hi Mario Vernari ,
We have reviewed your query. Based on the information you provided, we have
prepared a simple sample to replicate the issue using a GridCurrencyColumn.
We set the localization to German culture to enable the Euro currency and
applied a CellStyle to the currency column. The sample did not throw
any exceptions, and the cell style worked as expected.
We have provided the sample for your reference. Kindly review it and, to proceed further, please share details for the following queries:
- Could you please clarify how you are enabling the Euro currency?
- Could you please confirm whether you are using GridCurrencyColumn or any other column type?
- Kindly modify the provided sample to replicate your reported scenario.
This information will help us proceed further and provide
an accurate solution.
Regards,
Sweatha B
Attachment: Sample_5d115fe.zip
Hello Sweatha.
First off, I wasn't able to compile your sample. Despite I installed the latest SF suite, the project says there are 4 missing assemblies. Even trying to add them, it seems there's something wrong/missing. The compilation fails because "Syncfusion.Windows.Controls.Tools" is an unresolved namespace.
Never mind, though.
My fault, because I didn't specify earlier what project is the one that throws. That's the "syncfusion.datagriddemos.wpf_90". I use NET 9: I don't use Net Framework anymore.
That's the containing folder on my machine:
C:\Users\Public\Documents\Syncfusion\WPF\30.2.4\SampleBrowser\datagrid
BTW, my machine is a Windows 10 Pro x64, fully updated.
Well, to recreate the problem is straightforward.
If I set the regional settings to "English (USA)" there's no problem.
In the StyleConverterforQS2 converter I find these:
| Name | Value | Type | |
|---|---|---|---|
| value.ToString() | "$1,780,213.77" | string | |
| double.Parse(value.ToString(), NumberStyles.Currency) | 1780213.77 | double |
If I set to "Italian (Italia)" the exception is raised.
| Name | Value | Type | |
|---|---|---|---|
| value.ToString() | "716,788,57 €" | string | |
| ▶ | double.Parse(value.ToString(), NumberStyles.Currency) | 'double.Parse(value.ToString(), NumberStyles.Currency)' threw an exception of type 'System.FormatException' | double {System.FormatException} |
Please, note that I closed and restarted Visual Studio upon every regional settings change.
Of course, I didn't alter the original sources in any way, nor I did anything special in the app. Just run and select the
"Conditional Cell Style".
I have only two languages on my PC: Italian and English. I could install another one (e.g. German) if you need.
Thanks
Mario
Attachment: image_4_8bfe925.png
Thank you for the detailed follow-up and for providing the specific string you are working with.
Find the sample demo in the attachment and let us know if you have any concerns on this.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Attachment: Sample_7a7e7e1b.zip
Hello.
I marked your last answer as correct, but the problem is in your code, not mine. I have no code involving currency or similar. See my previous message.
However, I'd fix your code as follows.
First off, add the following static field in the control's backing code:
public partial class ConditionalFormattingDemo : DemoControl
{
public static readonly string CurrencyGroupSep = CultureInfo.CurrentCulture.NumberFormat.CurrencyGroupSeparator;
public ConditionalFormattingDemo()
{
InitializeComponent();
}
Then, in the control's XAML, patch every occurrence of this attribute as follows:
<syncfusion:GridCurrencyColumn
CurrencyGroupSeparator="{x:Static local:ConditionalFormattingDemo.CurrencyGroupSep}"
CurrencyGroupSizes="3"
HeaderText="Quarter1"
MappingName="QS1"
TextAlignment="Right" />
That works for me, and should work for any culture of the world. Hence, no exception!
Best
Mario
Mario Vernari ,
We glad that the
query was addressed from your side. Please get back to us if you need any
further assistance.
- 5 Replies
- 3 Participants
- Marked answer
-
MV Mario Vernari
- Aug 22, 2025 01:51 PM UTC
- Aug 27, 2025 03:44 PM UTC