13 Replies - 4421 Views - Last Post: 17 February 2012 - 07:30 AM Rate Topic: -----

#1 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

DateTimePicker language

Posted 16 February 2012 - 10:41 AM

is it possible to change language for days and months in datatimepicker? if no, then is it possible to display only numbers instead of names of the month?
Is This A Good Question/Topic? 1
  • +

Replies To: DateTimePicker language

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 16 February 2012 - 10:49 AM

I believe that's something you can set with the global culture bit, right?

http://msdn.microsof...ultureinfo.aspx
http://msdn.microsof...formatinfo.aspx
Was This Post Helpful? 1
  • +
  • -

#3 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 16 February 2012 - 11:02 AM

OK I see now,but i don't now anything about global culture. Ok, how can I apply this to my app, where to start?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 16 February 2012 - 11:19 AM

Read up on it first?

http://msdn.microsof...global/bb688096
Was This Post Helpful? 0
  • +
  • -

#5 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 16 February 2012 - 11:42 AM

I have try this. Still no results. But I think I'm close...or not?
 Dim DTF As New System.Globalization.DateTimeFormatInfo
        Dim strDays(6) As String
        strDays(0) = "Pon"
        strDays(1) = "Uto"
        strDays(2) = "Sri"
        strDays(3) = "Cet"
        strDays(4) = "Pet"
        strDays(5) = "Sub"
        strDays(6) = "Ned"
        DTF.AbbreviatedDayNames = strDays
        Dim cultInfo As New System.Globalization.CultureInfo("hr-HR")
        cultInfo.DateTimeFormat = DTF
        Application.CurrentCulture = cultInfo

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 16 February 2012 - 11:53 AM

More like this:
        Dim myDateTimeFormatInfo As System.Globalization.DateTimeFormatInfo = New Globalization.CultureInfo("hr-HR", False).DateTimeFormat '-- set the formatting.
        Dim myDateTime As New DateTime(2012, 2, 15) '-- make a datetime object

        Console.WriteLine(myDateTime.ToString("f", myDateTimeFormatInfo)) 'print it out
        'result: 
        '15. veljace 2012. 0:00


Was This Post Helpful? 1
  • +
  • -

#7 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 16 February 2012 - 01:03 PM

My datetimepicker language is still english.
Dim cultInfo As New System.Globalization.CultureInfo("hr-HR")
Dim myDateTimeFormatInfo As System.Globalization.DateTimeFormatInfo = New Globalization.CultureInfo("hr-HR", False).DateTimeFormat '-- set the formatting.
Dim strDays() As String = {"Pon", "Uto", "Sri", "Cet", "Pet", "Sub", "Ned"}
myDateTimeFormatInfo.AbbreviatedDayNames = strDays
cultInfo.DateTimeFormat = myDateTimeFormatInfo
Application.CurrentCulture = cultInfo


I've try to change first day of the week. This doesn't work either.
Application.CurrentCulture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday


Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 16 February 2012 - 01:16 PM

Oh.. with datetime *PICKER*... that unfortunately will have to be changed on the control panel level.

http://support.microsoft.com/kb/889834


else putting these lines before the 'initialize component' would have worked.

Thread.CurrentThread.CurrentCulture = New CultureInfo("hr-HR")
Thread.CurrentThread.CurrentUICulture = New CultureInfo("hr-HR")


Was This Post Helpful? 0
  • +
  • -

#9 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 16 February 2012 - 02:07 PM

View Postmodi123_1, on 16 February 2012 - 01:16 PM, said:

else putting these lines before the 'initialize component' would have worked.
Thread.CurrentThread.CurrentCulture = New CultureInfo("hr-HR")
Thread.CurrentThread.CurrentUICulture = New CultureInfo("hr-HR")


doesn't work either. I've put this code in form constructor just before 'initialize component'. In the link you provided it says: In the following Microsoft Visual Basic 2005 or Microsoft Visual Basic .NET example, when you set the CurrentUICulture property to fr_FR, the DateTimePicker control and the MonthCalendar control DO NOT display their user interface in French:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr")
     System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture
End Sub


I am confused now. What's that mean? Is it possible or not?
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 16 February 2012 - 02:09 PM

That's why I said "would have" worked... but those controls are common windows controls and you would need to change the culture in Window's Control Panel.
Was This Post Helpful? 0
  • +
  • -

#11 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 16 February 2012 - 02:46 PM

I now I can set language in control panel but this is not right solution for me. But thank you for your time! At last I've learn something about global culture. I've just checked in vb6 there is property 'first day of week' for monthview and calendar control, i was looking for this in datetimepicker, unfortunately this property doesn't exist, I must say I am a little bit disappointed, but never mind, i will create my own super datetimepicker!
Was This Post Helpful? 0
  • +
  • -

#12 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: DateTimePicker language

Posted 16 February 2012 - 04:50 PM

sela, you can set a custom format in the datetimepicker to just show the numbers instead of the names

Example
"MM/dd/yyyy" would give you 02/16/2012 or even "dd-MM-yyyy" giving you 16-02-2012

You need to set this format string in the CustomFormat and then set the Format Property to Custom.

Here's a list of custom format strings that you can use

This post has been edited by CharlieMay: 16 February 2012 - 04:52 PM

Was This Post Helpful? 0
  • +
  • -

#13 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: DateTimePicker language

Posted 17 February 2012 - 07:15 AM

Yes I know that, but this does not apply when you drop down datetimepicker and when you want to pick date, there is always month name shown instead of number..,the month name is on english, and the picker first day of the week is sunday. That's all is little confusing when you looking for a date and for someone who don't know english...but thanks.

This post has been edited by sela007: 17 February 2012 - 07:24 AM

Was This Post Helpful? 0
  • +
  • -

#14 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,293
  • Joined: 12-June 08

Re: DateTimePicker language

Posted 17 February 2012 - 07:30 AM

Yeah - that happens when MS connects the controls directly to to the Control Panel's settings and not something you can override. Their attempt of being helpful but in minor cases not.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1