Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

InputLanguage.FromCulture Method

Returns the input language associated with the specified culture.

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

public static InputLanguage FromCulture (
	CultureInfo culture
)
public static InputLanguage FromCulture (
	CultureInfo culture
)
public static function FromCulture (
	culture : CultureInfo
) : InputLanguage

Parameters

culture

The CultureInfo that specifies the culture to convert from.

Return Value

An InputLanguage that represents the previously selected input language.

The FromCulture method selects from among installed keyboards. Specifically, this method performs the following operations:

  1. Gets the LCID associated with culture.

  2. Gets the full list of available input language identifiers (HKLs) from the GetKeyboardLayoutList function.

  3. Finds the HKL that corresponds to the LCID from culture, if one is present.

  4. Returns the installed keyboard associated with that HKL.

  5. If no keyboard is found, returns a null reference (Nothing in Visual Basic).

NoteNote

The FromCulture method never tries to load or install an additional keyboard if one has not already been installed for culture. Use the Platform SDK function, LoadKeyboardLayout, to install an additional keyboard.

The following code example sets the default input language as the current input language.

First, DefaultInputLanguage is called to get the system default language. Next, CurrentInputLanguage is called to get the current input language. The results are printed in a text box. Then, calling CurrentInputLanguage with the default input language changes the current input language to the default. The new current input language is displayed in a text box.

This code assumes that textBox1 has been instantiated.

 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';
 
    //Print the new current input language.
    InputLanguage myCurrentLanguage2 = InputLanguage.CurrentInputLanguage;
    textBox1.Text += "New current input language is: " +
        myCurrentLanguage2.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');

    //Print the new current input language.
    InputLanguage myCurrentLanguage2 =
        InputLanguage.get_CurrentInputLanguage();
    textBox1.set_Text(textBox1.get_Text()
        + "New current input language is: "
        + myCurrentLanguage2.get_Culture().get_EnglishName());
} //SetNewCurrentLanguage

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.