GrayAreaColor - culture issues?

Posted by: berry on 8 September 2017, 1:49 pm EST

  • Posted 8 September 2017, 1:49 pm EST

    Hi,


     


    i'm getting the following error when setting the gray area color


    245,250,255 is not a valid value for Int32.


    Code used


    renderer = new FarPoint.Win.Spread.EnhancedInterfaceRenderer();


    renderer.GrayAreaColor = ColorTranslator.FromHtml("245,250,255")


    This happens only when i reset the current culture as


    System.Threading.Thread.CurrentThread.CurrentCulture


    = new System.Globalization.CultureInfo("fr-FR")


    Please help me get around this


     


    ~Berry 


     


     

  • Replied 8 September 2017, 1:49 pm EST

    Berry,


    The FromHtml method uses the current culture settings to parse the string.  In the "fr-FR" culture, the "," character is the decimal separator and the ";" character is the list separate.  Thus, the FromHtml method thinks the string is a floating point number rather that a list for three integers (as you wanted) and will raise an expection because the string is not in a valid format.  When using the "fr-FR" culture, you could use the following code...


        renderer.GrayAreaColor = ColorTranslator.FromHtml("245;250;255")


    If the current culture can vary in your application, then you could dynamically build the string using the current culture's list separator.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels