Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

InputLanguage Class

Provides methods and fields to manage the input language. This class cannot be inherited.

System.Object
  System.Windows.Forms.InputLanguage

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public sealed class InputLanguage

The InputLanguage type exposes the following members.

  NameDescription
Public propertyCultureGets the culture of the current input language.
Public propertyStatic memberCurrentInputLanguageGets or sets the input language for the current thread.
Public propertyStatic memberDefaultInputLanguageGets the default input language for the system.
Public propertyHandleGets the handle for the input language.
Public propertyStatic memberInstalledInputLanguagesGets a list of all installed input languages.
Public propertyLayoutNameGets the name of the current keyboard layout as it appears in the regional settings of the operating system on the computer.
Top
  NameDescription
Public methodEqualsSpecifies whether two input languages are equal. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberFromCultureReturns the input language associated with the specified culture.
Public methodGetHashCodeReturns the hash code for this input language. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

An input language is a culture/keyboard layout pair that determines how the physical keys on a keyboard map or plot to characters in a language. The input language is based on a Windows input locale identifier, such as that returned by the Platform SDK function, GetKeyboardLayout. The input locale identifier is also called a handle to a keyboard layout (HKL) value.

Use the static methods provided to find all installed mappings of the system and to change the input language for a thread or process. Call CurrentInputLanguage to get the current input language. Call DefaultInputLanguage for the default input language. Call InstalledInputLanguages to get all the installed languages in this system. After you have a list of all the installed languages, use CurrentInputLanguage to change the current input language to a different language.

The following code example gets a list of installed languages. The example requires that textBox1 has been instantiated and that textBox1.MultiLine has been set to true.


public void GetLanguages() {
    // Gets the list of installed languages.
    foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) {
       textBox1.Text += lang.Culture.EnglishName + '\n';
    }
}


The next example sets the default input language as the current input language. The example requires that textBox1 has been instantiated and that textBox1.MultiLine has been set to true.


public void SetNewCurrentLanguage() {
    // Gets the default, and current languages.
    InputLanguage myDefaultLanguage = InputLanguage.DefaultInputLanguage;
    InputLanguage myCurrentLanguage = InputLanguage.CurrentInputLanguage;
    textBox1.Text = "Current input language is: " + myCurrentLanguage.Culture.EnglishName + '\n';
    textBox1.Text += "Default input language is: " + myDefaultLanguage.Culture.EnglishName + '\n';

    // Changes the current input language to the default, and prints the new current language.
    InputLanguage.CurrentInputLanguage = myDefaultLanguage;
    textBox1.Text += "Current input language is now: " + myDefaultLanguage.Culture.EnglishName;
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.