PC Review


Reply
Thread Tools Rate Thread

Changing the CultureInfo

 
 
Jason L James
Guest
Posts: n/a
 
      26th Aug 2004
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.
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      26th Aug 2004
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
..


 
Reply With Quote
 
Jason L James
Guest
Posts: n/a
 
      26th Aug 2004
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

On Thu, 26 Aug 2004 13:17:31 +0200, "Cor Ligthert"
<(E-Mail Removed)> wrote:

>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
>.
>
>


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      26th Aug 2004
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
///


 
Reply With Quote
 
Jason L James
Guest
Posts: n/a
 
      26th Aug 2004
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.

On Thu, 26 Aug 2004 14:07:45 +0200, "Cor Ligthert"
<(E-Mail Removed)> wrote:

>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
>///
>
>


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      26th Aug 2004
* (E-Mail Removed) (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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CultureInfo and RTL Oscar Thornell Microsoft C# .NET 2 26th Sep 2006 12:48 PM
Changing Globalization CultureInfo Alvaro E. Gonzalez V. Microsoft C# .NET 1 23rd Jul 2005 11:30 AM
Changing Globalization CultureInfo Alvaro E. Gonzalez V. Microsoft Dot NET Framework 1 22nd Jul 2005 06:29 PM
CultureInfo Urs Vogel Microsoft VB .NET 2 20th Jul 2004 07:50 PM
Changing CultureInfo G?rken Pamuk via .NET 247 Microsoft Dot NET Compact Framework 0 3rd Jul 2004 03:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 PM.