Edit

Share via


InputLanguage Class

Definition

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

C#
public sealed class InputLanguage
Inheritance
InputLanguage

Examples

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.

C#
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.

C#
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;
}

Remarks

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.

Properties

Culture

Gets the culture of the current input language.

CurrentInputLanguage

Gets or sets the input language for the current thread.

DefaultInputLanguage

Gets the default input language for the system.

Handle

Gets the handle for the input language.

InstalledInputLanguages

Gets a list of all installed input languages.

LayoutName

Gets the name of the current keyboard layout as it appears in the regional settings of the operating system on the computer.

Methods

Equals(Object)

Specifies whether two input languages are equal.

FromCulture(CultureInfo)

Returns the input language associated with the specified culture.

GetHashCode()

Returns the hash code for this input language.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9