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

5 Replies 1 reply marked as answer

SB Sweatha Bharathi Syncfusion Team August 25, 2025 12:54 PM UTC

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:


  1. Could you please clarify how you are enabling the Euro currency?
  2. Could you please confirm whether you are using GridCurrencyColumn or any other column type?
  3. 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


MV Mario Vernari August 26, 2025 03:31 AM UTC

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:

Document
NameValueType
value.ToString()"$1,780,213.77"string
double.Parse(value.ToString(), NumberStyles.Currency)1780213.77double


If I set to "Italian (Italia)" the exception is raised.

Document
NameValueType
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



SB Sweatha Bharathi Syncfusion Team August 26, 2025 11:02 AM UTC

Mario Vernari ,

Thank you for the detailed follow-up and for providing the specific string you are working with.
We have successfully replicated the scenario you reported. The issue occurs because the string "716,788,57 €" mixes the formatting rules of both the English and Italian cultures. To parse correctly, a string must strictly follow the rules of a single culture.

For instance, when using the Italian culture, the parser sees the first comma in "716," and correctly treats it as the decimal separator. However, when it encounters the second comma in "788,", it sees a second decimal separator, which makes the number format invalid.

To parse the number properly, the string format must exactly match the culture's rules. To avoid this parsing error, kindly use the below following format:

Correct format for Italian (it-IT): "716.788,57 €" (using periods for thousands separators and a comma for the decimal).

We hope this explanation helps clarify the issue. 

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

Marked as answer

MV Mario Vernari August 26, 2025 01:23 PM UTC

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



EE Elavazhagan Elangovan Syncfusion Team August 27, 2025 03:44 PM UTC

Mario Vernari ,

We glad that the query was addressed from your side. Please get back to us if you need any further assistance.


Loader.
Up arrow icon