如何在VB.NET中单击按钮切换表单语言?
我想创建本地化的应用程序,并想要实现语言切换器(例如特殊按钮).我使用Visual Studio 2010 Express(VB.NET).
I want to create the localized application and want to implement a language switcher (e.g. special button). I use Visual Studio 2010 express (VB.NET).
我创建了一个带有一个标签和一个按钮的简单测试应用程序.我将表单的属性"Localizable"设置为"True",并用两种语言(默认英语和俄语)编辑了组件的文本.
I created simple test app with one label and one button. I set form's property "Localizable" to "True" and edited components' text in 2 languages (English as default and Russian).
我知道需要添加
Imports System.Threading.Thread
Imports System.Globalization
在Form1.vb的开头,然后使用
at the beginning of the Form1.vb and then use
Thread.CurrentThread.CurrentUICulture = New CultureInfo("ru")
启用俄语本地化. 但是,如果我将此行放入Button_Click事件中,则不会更改语言.是否可以在按钮单击或组合框更改之类的事件之间切换语言?
to enable Russian localization. But if I put this line into Button_Click event it does not change the language. Is it possible to switch between languages on event like button click or combobox change?
提前谢谢!
是的,您可以在Button Click事件或change事件上实现本地化.您可以将文化设置为
Yes you can implement localization on Button Click event or on a change event. You can set the culture as
Thread.CurrentThread.CurrentUICulture = New CultureInfo("ru-RU")
这些链接将为您提供帮助:全球化和本地化Windows应用程序,演练:本地化Windows窗体,
These links will help you : Globalizing and Localizing Windows Application, Walkthrough: Localizing Windows Forms, Localizing Applications