DatePicker and localization

thegios

New member
Joined
Mar 24, 2005
Messages
1
Programming Experience
5-10
Consider a form with a DatePicker1 and a Button1: each time I press Button1 I want the current culture to change from en-US to it-IT, then Button1 text should diplay the current date in the current culture format and the same for DatePicker1.
Here's the code

-----------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static b As Boolean
Dim dt As DateTime = New DateTime
If b Then
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
Else
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("it-IT")
End If

Me.Text = System.Threading.Thread.CurrentThread.CurrentCulture.ToString
dt = DateTime.Now
Button1.Text = dt.ToString("d")
DateTimePicker1.Value = dt
b = Not b
End Sub
-----------------------

The problem is that it works for Button1 text but not for DatePicker1, whose format remains in Italian (which is what Windows is set to).
How can I make the a DatePicker localizeable?

thanks
 
Back
Top