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.

For a list of all members of this type, see InputLanguage Members.

System.Object
   System.Windows.Forms.InputLanguage

[Visual Basic]
NotInheritable Public Class InputLanguage
[C#]
public sealed class InputLanguage
[C++]
public __gc __sealed class InputLanguage
[JScript]
public class InputLanguage

Thread Safety

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

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.

Use the static (Shared in Visual Basic) 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. Once you have a list of all the installed languages, use CurrentInputLanguage to change the current input language to a different language.

Example

[Visual Basic, C#, C++] The following example gets a list of installed languages. It assumes that textBox1 has been instantiated and that textBox1.MultiLine has been set to true.

[Visual Basic] 
Public Sub GetLanguages()
    ' Gets the list of installed languages.
    Dim lang As InputLanguage
    For Each lang In  InputLanguage.InstalledInputLanguages
        textBox1.Text &= lang.Culture.EnglishName & ControlChars.Cr
    Next lang
End Sub 'GetLanguages


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

[C++] 
public:
void GetLanguages() {
    // Gets the list of installed languages.
    System::Collections::IEnumerator* myEnum = InputLanguage::InstalledInputLanguages->GetEnumerator();
    while (myEnum->MoveNext())
    {
        InputLanguage* lang = __try_cast<InputLanguage*>(myEnum->Current);
        textBox1->Text = String::Concat( textBox1->Text, lang->Culture->EnglishName, S"\n" );
    }
}

[Visual Basic, C#, C++] The next example sets the default input language as the current input language. It assumes that textBox1 has been instantiated and that textBox1.MultiLine has been set to true.

[Visual Basic] 
Public Sub SetNewCurrentLanguage()
    ' Gets the default, and current languages.
    Dim myDefaultLanguage As InputLanguage = InputLanguage.DefaultInputLanguage
    Dim myCurrentLanguage As InputLanguage = InputLanguage.CurrentInputLanguage
    textBox1.Text = "Current input language is: " & _
        myCurrentLanguage.Culture.EnglishName & ControlChars.Cr
        
    textBox1.Text &= "Default input language is: " & _
        myDefaultLanguage.Culture.EnglishName & ControlChars.Cr
    
    ' 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
End Sub 'SetNewCurrentLanguage

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

[C++] 
public:
void SetNewCurrentLanguage() {
    // Gets the default, and current languages.
    InputLanguage* myDefaultLanguage = InputLanguage::DefaultInputLanguage;
    InputLanguage* myCurrentLanguage = InputLanguage::CurrentInputLanguage;
    textBox1->Text = String::Format( S"Current input language is: {0}\nDefault input language is: {1}\n",
        myCurrentLanguage->Culture->EnglishName, myDefaultLanguage->Culture->EnglishName );
 
    // Changes the current input language to the default, and prints the new current language.
    InputLanguage::CurrentInputLanguage = myDefaultLanguage;
    textBox1->Text = String::Format( S"{0}Current input language is now: {1}", textBox1->Text, myDefaultLanguage->Culture->EnglishName );
}

[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

Namespace: System.Windows.Forms

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

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

InputLanguage Members | System.Windows.Forms Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.