FlexRerport Field Date format

Posted by: brezodejan on 31 October 2019, 6:06 pm EST

    • Post Options:
    • Link

    Posted 31 October 2019, 6:06 pm EST

    Hi guys,

    Is there any way to set Date format on Field to use CultureInfo from my app.

    It seams as like always use CultureInfo from my computer settings.

  • Posted 31 October 2019, 6:59 pm EST

    Hi,

    make this call before the report is generated:

    
    System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("de-DE");
    
    

    Hope this helps

    Wolfgang

  • Posted 1 November 2019, 1:11 am EST

    I do that. Actually, I change formats in CurrentCulture for “en-US” and when I check it in debbuger in FlexReport.ActualCulture, everything is OK, but I don’t get formatted Date on generated Report

    PS:

    "System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("de-DE")"
    ``` doesn't work because of compiler error: [i]Property 'CurrentCulture' is 'ReadOnly'.[/i]
  • Posted 1 November 2019, 1:12 am EST - Updated 3 October 2022, 3:35 pm EST

  • Posted 1 November 2019, 1:39 am EST

    Seems you use .NET 4.5, where this property is readonly - I tested it with 4.6.

    You might follow the suggestion from here:

    https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=netframework-4.8

    “To change the current culture, you assign the CultureInfo object that represents the new culture to the Thread.CurrentThread.CurrentCulture property”

    Best regards

    Wolfgang

  • Posted 1 November 2019, 3:16 am EST

    I know how to change the culture settings, and as I said before:

    I change culture settings in the other way. I attached the picture with debugger settings and values I’ve already set. I show you on picture that the property ActualCulture has changed formats. But, the format on generated reports is like in System Culture settings.

    I have to use .net framework 4.0

    I don’t expect that the usage of this version of framework is problem or…?

  • Posted 2 November 2019, 1:35 am EST

    Hello,

    I investigate and realized that the problem is more complex. You are right - everything is working if the date field is in main report.

    But problem is if you have date field in a subreport.

    I will attach the simple example and I hope that you will give me a way how to resolve the issue.WindowsFormsApp1.zip

  • Posted 3 November 2019, 5:24 pm EST

    Hello,

    You can set the culture of subreport explicitly like as follow:

    
        this.c1FlexReport1.Culture = new System.Globalization.CultureInfo("en-US");
                this.c1FlexReport1.Culture.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy";
            
                this.c1FlexReport1.Load("..\\..\\Report1.flxr", "New Report");
           
               (this.c1FlexReport1.Sections["Detail"].Fields[1] as C1.Win.FlexReport.SubreportField).Subreport.Culture = new System.Globalization.CultureInfo("en-US");
                   (this.c1FlexReport1.Sections["Detail"].Fields[1] as C1.Win.FlexReport.SubreportField).Subreport.Culture.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy";
                   this.c1FlexViewer1.DocumentSource = this.c1FlexReport1;
    
    

    Hope it helps.

    Thanks,

    Mohit

Need extra support?

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

Learn More

Forum Channels