Export (0) Print
Expand All

Thread.CurrentUICulture Property

Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run time.

[Visual Basic]
Public Property CurrentUICulture As CultureInfo
[C#]
public CultureInfo CurrentUICulture {get; set;}
[C++]
public: __property CultureInfo* get_CurrentUICulture();
public: __property void set_CurrentUICulture(CultureInfo*);
[JScript]
public function get CurrentUICulture() : CultureInfo;
public function set CurrentUICulture(CultureInfo);

Property Value

A CultureInfo representing the current culture.

Exceptions

Exception Type Condition
ArgumentNullException The property value is a null reference (Nothing in Visual Basic).

Example

[Visual Basic, C#, C++] The following code example shows the threading statement that allows the user interface of a Windows Forms to display in the culture that is set in Control Panel. Additional code is needed.

[Visual Basic] 
' Compile with option t:winexe /r:System.dll,System.Windows.Forms.dll.

Option Explicit
Option Strict

Imports System
Imports System.Threading
Imports System.Windows.Forms

Public Class UICulture
    Inherits Form

    Sub New()

        ' Set the user interface to display in the
        ' same culture as that set in Control Panel.
        Thread.CurrentThread.CurrentUICulture = _
            Thread.CurrentThread.CurrentCulture

        ' Add additional code.
    End Sub

    <STAThreadAttribute> Shared Sub Main()
        Application.Run(New UICulture())
    End Sub

End Class

[C#] 
// Compile with option /t:winexe.

using System;
using System.Threading;
using System.Windows.Forms;

class UICulture : Form
{
    public UICulture()
    {
        // Set the user interface to display in the
        // same culture as that set in Control Panel.
        Thread.CurrentThread.CurrentUICulture = 
            Thread.CurrentThread.CurrentCulture;

        // Add additional code.
    }

    [STAThreadAttribute]
    static void Main()
    {
        Application.Run(new UICulture());
    }
}

[C++] 
#using <mscorlib.dll>
#using <system.dll>
#using <system.windows.forms.dll>

using namespace System;
using namespace System::Threading;
using namespace System::Windows::Forms;

__gc class UICulture : public Form
{
public:
    UICulture()
    {
        // Set the user interface to display in the
        // same culture as that set in Control Panel.
        Thread::CurrentThread->CurrentUICulture = 
            Thread::CurrentThread->CurrentCulture;

        // Add additional code.
    }
};

[STAThreadAttribute]
void WinMain()
{
    Application::Run(new UICulture());
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Thread Class | Thread Members | System.Threading Namespace

Show:
© 2014 Microsoft