changing culture on datetimepicker

M

marcussilfver

I want to change the culture on a DateTimePicker

The code below works somewhat. I get the date in english format when
dateTimePicker1 is not expanded. When I click dateTimePicker1 in my
application GUI though (and thereby expands dateTimePicker1, showing
the dates of the month) at the bottommost I see todays date written in
swedish format. Of course I want this to be in english format as well,
but how do I do it?

thanks.

Here is the code:

// set up some culture variables
private ResourceManager m_ResourceManager = new
ResourceManager("myApp.dictionary",
System.Reflection.Assembly.GetExecutingAssembly());
private CultureInfo m_EnglishCulture = new CultureInfo("en-US",true);
private CultureInfo m_SwedishCulture = new CultureInfo("sv-SE", true);

// set which culture to use
Thread.CurrentThread.CurrentUICulture = m_EnglishCulture;

// In my update GUI method: if culture is english => change format of
date
if (CultureInfo.CurrentUICulture.Name == "en-US")
{
this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = "MM'/'dd'/'yyyy'";
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top