Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How To Use Resources in Visual Basic .NET
 

How To Use Resources in Visual Basic .NET

Hi MSDN menber !
I want create project which can automatic change languages when System regional languages change
please tell me the way to do
Thanks
Le Minh Hai  Wednesday, September 24, 2008 4:19 AM

Hi Le Minh Hai,

I am not sure about the meaning of “automatic�very clearly. Do you want the application to change language once the regional language changes or the application will change after restarting itself? The latter one will be easy to accomplish.

As we all know, if we want to localize our application, we may first create different language resources.

Supposewe want to create Chinese language resource, we will do the following steps:

1. Choose the form, and set the localizable property to true.

2. Set the language to “Chinese (Simplified)�

3. Change the property of the controls which you want to localize. Such as Text property of the labels or buttons.

4. Build the solution. The Chinese language resources will be generated for you.

The last thing we need to do is:

Before the InitializeComponent property, add the following statement. The application will display the language which is set in the control panel.

Code Snippet

Public Sub New()

System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentThread.CurrentCulture

InitializeComponent()

End Sub

It may be difficult for us to change the application language immediatelysince the System.Threading.Thread.CurrentThread.CurrentCulture will not change after the application restarts. However, we can capture the regional languages changed event in our application.

If you have further problems or difficulty in understanding me, please feel free to contact me.

Best Regards,

Bruce Zhou

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Bruce.Zhou  Friday, September 26, 2008 2:52 AM

Hi Le Minh Hai,

I am not sure about the meaning of “automatic�very clearly. Do you want the application to change language once the regional language changes or the application will change after restarting itself? The latter one will be easy to accomplish.

As we all know, if we want to localize our application, we may first create different language resources.

Supposewe want to create Chinese language resource, we will do the following steps:

1. Choose the form, and set the localizable property to true.

2. Set the language to “Chinese (Simplified)�

3. Change the property of the controls which you want to localize. Such as Text property of the labels or buttons.

4. Build the solution. The Chinese language resources will be generated for you.

The last thing we need to do is:

Before the InitializeComponent property, add the following statement. The application will display the language which is set in the control panel.

Code Snippet

Public Sub New()

System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentThread.CurrentCulture

InitializeComponent()

End Sub

It may be difficult for us to change the application language immediatelysince the System.Threading.Thread.CurrentThread.CurrentCulture will not change after the application restarts. However, we can capture the regional languages changed event in our application.

If you have further problems or difficulty in understanding me, please feel free to contact me.

Best Regards,

Bruce Zhou

Windows Forms General FAQs
Windows Forms Data Controls and Databinding FAQs

Bruce.Zhou  Friday, September 26, 2008 2:52 AM
Hi Bruce Zhou-MSFT

Yes, I want create the application which have two language ( Ex : English and Chinese) when
regional language changes and restart my application will be change

Your code you gave me really useful my application work very good !
Thanks a lot !

Le Minh Hai  Monday, September 29, 2008 12:34 AM
Hi Bruce Zhou,

I have an application where the infopath form has to be changed into a particular language once user selects the required language in the form. I have a .net windows application included in the form. So, depending on the language selected, I want this windows application to be displayed in the same language. But I was not able to do that and implemented the steps suggested by you. I followed the below 2 steps:

1. Choose the form, and set the localizable property to true.

2. Set the language to “Chinese (Simplified)�

But could not understand the 3rd step:

3. Change the property of the controls which you want to localize. Such as Text property of the labels or buttons.
What do you mean by changing the 'Text' property? I have some text in English language in the label'sproperty.

Could you please elaborate this point?

Thanks!
Pria

Priya Darshini  Tuesday, June 16, 2009 12:31 PM
Hi Pria.Chilamkurthi,

Yes, for example, there's a button in the form whose Text property is "Time". After the second step, we can set the Text property of the button in the PropertyGrid to "æ—¶é—´"(The Chinese translation of "Time"), and rebuild the project, Visual Studio will generate the resource file for Chinese language.

Feel free to let me know if you are still not clear.


Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Wednesday, June 17, 2009 9:56 AM

You can use google to search for other answers

Custom Search

More Threads

• Form Designer; w/ Custom Properties
• UITypeEditor - Get Component Instance
• UserControl custom property and UndoEngine
• Strange Behaviour of Combobox created as Custom by inheriting from Actual
• ToolStripControlHost - Designer functionality
• Custom Property Editor Woes
• Working the scripts and the cookies .in WebBrowser Control?
• Disappearing Tab Controls
• Designer duplicates resources used from an external project?
• Unwanted Focus to FlowLayoutPannel