

' Apply the locale to the form's controls.Ĭomponent_resource_manager, culture_info) ' Debug.WriteLine("$this")Ĭomponent_resource_manager.ApplyResources(Me, "$this", _ This doesn't change ' existing controls but will apply to those loaded later ' and to messages we get for Help About (see below). ' Make a CultureInfo and ComponentResourceManager.ĭim culture_info As New CultureInfo(locale_name) Private Sub ApplyLocale(ByVal locale_name As String) ' Apply a locale to the form and its controls. Similarly the program loads a ToolStripComboBox. Note that the strings you put in these controls at design time are named Items, Items1, Items2, etc. It uses the ResourceManager to fetch the appropriate values from the resource files.
MENUSTRIP VB.NET HOW TO
Because they are items, the ComponentResourceManager cannot know how to load their values so the program does it. The program shows how to set a tooltip, using the ResourceManager to get the appropriate text.ĬomboBoxes and ListBoxes contain lists of items. Tooltips are provided by a ToolTip extender provider so they are not true properties and are not loaded by the ComponentResourceManager. The program makes a ResourceManager to load resources from the correct vesion of the form's resource file. That takes care of basic properties but there are some things it doesn't handle so the program must handle them itself. It then loops through the form's controls and calls subroutine ApplyLocaleToControl for each.
MENUSTRIP VB.NET CODE
The code uses the ComponentResourceManager to load the form's properties. It sets the thread's culture properties to the locale. It creates a CultureInfo object to represent the locale and a ComponentResourceManager to load resources for the locale. Subroutine ApplyLocale applies a new locale. Normally Visual Basic examines the computer's regional settings to decide which resources to use but you can change this for testing purposes at run time. If you click the Solution Explorer's Show All Files button, you can see these files below the form. When you do this, Visual Basic stores information for the different languages in different resource files associated with the form. For example, translate the text into the new language. Change the controls' properties for the new language. Then set the form's Localizable property to True and set its Language property to another language that you want to support. Locale, internationalization, globalization, CultureInfo, runtimeįirst, build the form as you normally would. This example shows how to localize control resources at run time in VB. Localize control resources at run time in VB. VB Helper: HowTo: Localize control resources at run time in VB.
