Export (0) Print
Expand All
1 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.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public sealed class InputLanguage
public final class InputLanguage
public final class InputLanguage

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';
    }
}

public void GetLanguages()
{
    // Gets the list of installed languages.
    IEnumerator objEnum = InputLanguage.get_InstalledInputLanguages().
        GetEnumerator();
    while (objEnum.MoveNext()) {
        InputLanguage lang = (InputLanguage)objEnum.get_Current();
        textBox1.set_Text(textBox1.get_Text() + lang.get_Culture().
            get_EnglishName() + '\n');
    }
} //GetLanguages

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

public void SetNewCurrentLanguage()
{
    // Gets the default, and current languages.
    InputLanguage myDefaultLanguage =
        InputLanguage.get_DefaultInputLanguage();
    InputLanguage myCurrentLanguage =
        InputLanguage.get_CurrentInputLanguage();
    textBox1.set_Text("Current input language is: "
        + myCurrentLanguage.get_Culture().get_EnglishName() + '\n');
    textBox1.set_Text(textBox1.get_Text() + "Default input language is: "
        + myDefaultLanguage.get_Culture().get_EnglishName() + '\n');

    // Changes the current input language to the default, 
    // and prints the new current language.
    InputLanguage.set_CurrentInputLanguage(myDefaultLanguage);
    textBox1.set_Text(textBox1.get_Text()
        + "Current input language is now: "
        + myDefaultLanguage.get_Culture().get_EnglishName());
} //SetNewCurrentLanguage

System.Object
  System.Windows.Forms.InputLanguage
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.