UICulture Property
Collapse the table of content
Expand the table of content

ApplicationBase.UICulture Property

Gets the culture that the current thread uses for retrieving culture-specific resources.

Namespace:  Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public CultureInfo UICulture { get; }

Property Value

Type: System.Globalization.CultureInfo
A CultureInfo object that represents the culture that the current thread uses for retrieving culture-specific resources.

The My.Application.CurrentUICulture property gets the CultureInfo object that the current thread uses for retrieving culture-specific resources. This object is identical to the one returned by the CurrentUICulture property. The CurrentUICulture property determines the culture used by the Resource Manager and the My.Resources object, information it needs to look up culture-specific resources at run time.

To change the culture, you can use the ChangeUICulture method or assign a different CultureInfo object to the CurrentUICulture property.

The CurrentCulture setting is different from a language setting. It contains only data related to the standard settings for a geographical region.

Use the My.Application.CurrentCulture property to get the culture that the current thread uses for string manipulation and string formatting.

Availability by Project Type

Project type

Available

Windows Forms Application

Yes

Class Library

Yes

Console Application

Yes

Windows Forms Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

This example uses the My.Application.CurrentCulture property to cache the current culture before changing it by using ChangeUICulture. The My.Application.ChangeUICulture method sets the culture that the My.Resources object uses for retrieving resources.


Sub ShowLocalizedMessage()
    Dim culture As String = My.Application.UICulture.Name
    My.Application.ChangeUICulture("fr-FR")
    MsgBox(My.Resources.Message)
    My.Application.ChangeUICulture(culture)
End Sub


For this example to work, your application must have a string named Message in the application's resource file, and the application should have the French-culture version of that resource file, Resources.fr-FR.resx. For more information, see How to: Add or Remove Resources.

If the application does not have the French-culture version of that resource file, the My.Resources object retrieves the resource from the default-culture resource file.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2016 Microsoft