CultureInfo support for DateTime DataColumn.

Apr 25, 2012 at 2:20 PM
Edited Apr 25, 2012 at 2:22 PM


I'm French, i'm really sorry for my english skills.


First, I'd like to congratulate you for your great job. 


I've got one problem with the datetime sort :

In my DataTable, i set the DatacolumnType to Datetime. (new DataColumn("Date"){ DataType = typeOf(DateTime) })

I set the value to DateTime too, and it works fine but i have a datetime in this format MM/dd/yyyy. I want it in this format dd/MM/yyyy (like the FR culture.)


I tried to set the value with a DateTime.Parse(MyStringDate,new CultureInfo("fr-FR")) but it doesn't work.



Could you please tell me if the culture info is supported?


Thanks for all.




Apr 25, 2012 at 4:00 PM

Hi, thanks for taking a look at this piece of code, I wrote it waaay back and I can hardly remember what it was all about. ;-)

So it seems you're having a problem because the display format of the dates is coming incorrectly? The BindableDataGrid class inherits from the default DataGrid, so I *guess* the dates should be treated as per the current culture in your application, I haven't messed around with anything.

Having said that, it seems there *could* be an issue related to the fact that the CreateColumns method treats most of the types as strings (

I can take a look (when I have some time ;-D) and try to see it fixed...

Apr 25, 2012 at 4:28 PM

Hi again, I did a quick an dirty test to set the culture to french in the MainPage file of the application adding the following lines to the main page of the demo project and after reading this post:


        public MainPage()
            CultureInfo ci = new CultureInfo("fr-fr");
            System.Threading.Thread.CurrentThread.CurrentCulture = ci;
            this.Language = XmlLanguage.GetLanguage(System.Threading.Thread.CurrentThread.CurrentCulture.Name);


The date time field is now showing correctly in French format and you can even sort it. :-)


Apr 26, 2012 at 6:42 AM

oO..... my apologize....i was trying to set the culture in the wrong file....

That works perfectly...

Sorry for that and thanks for all!


Apr 26, 2012 at 4:55 PM

No need to apologize, I'm glad to know that someone is using my code! :-D
If it's something freely accessible maybe you can send me a link when you're finished so I can take a peek at what you've done (just out of curiosity), as I created it as a "style exercise" but never actually implemented it in any project at all.

Kind regards.