473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Change CurrentUICulture, controls doesn't refresh

Dear all,

My application allows users to switch languages at run time. I use the
following code to change the UI Culture but all controls are remaining
unchanged.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Why? Anything that I need to do in order to refresh the controls?

Thanks for any help!

Tedmond


Mar 15 '06 #1
4 16696
Tedmond wrote:
Dear all,

My application allows users to switch languages at run time. I use the
following code to change the UI Culture but all controls are remaining
unchanged.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Why? Anything that I need to do in order to refresh the controls?

Thanks for any help!

Tedmond


Change "CurrentUICulture" will not automatically take effect in all UI
control.

Change "CurrentUICulture" just affect some APIs which are releated to
localization.
For example, "System.Resources.ResourceManager.GetString(.. .)", then it
will use the current "CurrentUICulture" to load suitable string resources.

For Windows.Form UI control, you need to reload all the resource strings
after change the "CurrentUICulture".
--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk
Mar 15 '06 #2
Hi Jacky,

I tried to call InitializeComponent() again after changing the
CurrentUICulture. I found it reload all the resource strings and all the
values are updated, however the display remains unchanged. Why? For
example, when I debug the program I found a button .Text property is updated
after changing the CurrentUICulture but the screen still showing the original
language.

Any more idea?

Thanks.

"jacky kwok" wrote:
Tedmond wrote:
Dear all,

My application allows users to switch languages at run time. I use the
following code to change the UI Culture but all controls are remaining
unchanged.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Why? Anything that I need to do in order to refresh the controls?

Thanks for any help!

Tedmond


Change "CurrentUICulture" will not automatically take effect in all UI
control.

Change "CurrentUICulture" just affect some APIs which are releated to
localization.
For example, "System.Resources.ResourceManager.GetString(.. .)", then it
will use the current "CurrentUICulture" to load suitable string resources.

For Windows.Form UI control, you need to reload all the resource strings
after change the "CurrentUICulture".
--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk

Mar 15 '06 #3
Tedmont,

The culture settings are affected to the culture setting as decimal point
and datetime representation, not direct to the used language. Because these
cultures can be depended from the language used in those countries is the
complete culture setting needed. (Think by instance to Canada, which uses
the culture from French and from England (not from the USA)).

Cor
Mar 15 '06 #4
Tedmond wrote:
Hi Jacky,

I tried to call InitializeComponent() again after changing the
CurrentUICulture. I found it reload all the resource strings and all the
values are updated, however the display remains unchanged. Why? For
example, when I debug the program I found a button .Text property is updated
after changing the CurrentUICulture but the screen still showing the original
language.

Hi Tedmond:

I do not sure what is your problem.
In my own app, it works.

Moreover, you should not call "InitializeComponent()" directly. The VS
generated "InitializeComponent()" not only loads string resource but
also creates all the child controls.
I believe it will raise exception when you call it again.
You should copy the code in "InitializeComponent()" which are related to
the localization resource in another function.

/// It is my example i na Form "FormMain"
.....
System.Threading.Thread.CurrentThread.CurrentUICul ture = new
System.Globalization.CultureInfo(lang); //my selected lang from menu

ReloadControlString();

///
private void ReloadControlString()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(FormMain)) ;

this.menuApp.Text = resources.GetString("menuApp.Text");
.........
}
///
Make sure you have made the correct localization resource for your
control. You can use debugger to check what string is loaded.


--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk
Any more idea?

Thanks.

"jacky kwok" wrote:
Tedmond wrote:
Dear all,

My application allows users to switch languages at run time. I use the
following code to change the UI Culture but all controls are remaining
unchanged.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Why? Anything that I need to do in order to refresh the controls?

Thanks for any help!

Tedmond

Change "CurrentUICulture" will not automatically take effect in all UI
control.

Change "CurrentUICulture" just affect some APIs which are releated to
localization.
For example, "System.Resources.ResourceManager.GetString(.. .)", then it
will use the current "CurrentUICulture" to load suitable string resources.

For Windows.Form UI control, you need to reload all the resource strings
after change the "CurrentUICulture".
--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk

Mar 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: DraguVaso | last post by:
Hi, I have a Windows Service running (made in VB.NET), and wanted to be able to change from time to time some parameters by changing them in the App.config. But it seems that the application...
1
by: Amy | last post by:
What's different between Controls method Refresh() and Invalidate(), Refresh() and Update()? Your help will be appreciated. Thanks.
2
by: John | last post by:
Hi. When I use VB.NET projects, Visual Studio refreshes the display when I correct errors. (i.e. removes the blue and red lines under syntax errors etc.) But when I use C# projects, the display...
8
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page...
2
by: Ned Balzer | last post by:
Hi, Apologies if this is a newbie question, I haven't found the answer in any faqs. I have an asp.net 2.0 page that sets session variables and then redirects to another page. For the page...
1
by: Orit | last post by:
Hi . I am creating an ASP.NET 2.0 web site and have the following problem : 1. I have a GridView which bound to the object data source. 2. This object data source is SQL Table adapter that I...
7
by: seanmatthewwalsh | last post by:
Hi I have a page (default.aspx) that pulls it's HTML from a database. I then have a "content management" page (editpage.aspx) that allows the user to edit the HTML in the database. When the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.