By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,350 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,350 IT Pros & Developers. It's quick & easy.

changing culture on datetimepicker

P: n/a
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'";
}

Apr 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,
i dont know if the following link will help you
http://forums.microsoft.com/msdn/sho...49473&siteid=1

Husam Al-a'araj

"ma***********@gmail.com" wrote:
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'";
}

Apr 21 '07 #2

P: n/a
Hi,

Unfortunately it won't be possible with the Microsoft DateTimePicker:
http://support.microsoft.com/Default...9834&x=18&y=19

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com

On Apr 21, 2:59 am, marcussilf...@gmail.com wrote:
I want to change thecultureon aDateTimePicker

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 someculturevariables
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 whichcultureto use
Thread.CurrentThread.CurrentUICulture = m_EnglishCulture;

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

}

Apr 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.