Changing the CultureInfo

  • Thread starter Thread starter Jason L James
  • Start date Start date
J

Jason L James

Hi have two subroutines that change the currentCulture
property of my application.

I can call either:

System.Threading.Thread.CurrentThread.CurrentCulture = New
CultureInfo("en-GB")

or:

System.Threading.Thread.CurrentThread.CurrentCulture = New
CultureInfo("es-ES")


In my form load event I call this code:

Label1.Text = Format(500.5, "Currency")

However, I expected the format oif the string in the label to
be updated when the cultureInfo is changed. It does not! Am
I doing anything wrong?

Thanks,

Jason.
 
Jason,

A string is never updated by the culture info

It should update after have set the culture and than do by instance
mylabel = Now.tostring

I hope this helps?

Cor
..
 
Cor,

am I correct in saying that any changes to the culture info
during the execution of the application will not be reflected
in the formatting of the currency values, etc until the
program is started again?

I was trying the do this with my two buttons on a form, but
when I changed culture info nothing happened unless I
updated the value manually.

Thanks,

Jason
 
Jason,

Try this

I hope this helps?

Cor

\\\Needs a new project a label and a button
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.CurrentThread.CurrentCulture = _
New Globalization.CultureInfo("en-GB")
Label1.Text = Format(500.5, "Currency")
End Sub

Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Threading.Thread.CurrentThread.CurrentCulture.ToString = "es-ES"
Then
Threading.Thread.CurrentThread.CurrentCulture = _
New Globalization.CultureInfo("en-GB")
Else
Threading.Thread.CurrentThread.CurrentCulture = _
New Globalization.CultureInfo("es-ES")
End If
Me.Label1.Text = Format(500.5, "Currency")
End Sub
///
 
Cor,

thanks. It looks like I need to manually refresh the textboxes if
the culture info is changed during the execution of my app.

Thanks for the clarification.

Jason.
 
* (e-mail address removed)-master.org (Jason L James) scripsit:
Label1.Text = Format(500.5, "Currency")

However, I expected the format oif the string in the label to
be updated when the cultureInfo is changed. It does not! Am
I doing anything wrong?

You will have to reload everything to see it reflecting the new culture
settings.
 
Back
Top