NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

InputLanguage.FromCulture

Returns the input language associated with the specified culture.

[Visual Basic]
Public Shared Function FromCulture( _
   ByVal culture As CultureInfo _
) As InputLanguage
[C#]
public static InputLanguage FromCulture(
   CultureInfo culture
);
[C++]
public: static InputLanguage* FromCulture(
   CultureInfo* culture
);
[JScript]
public static function FromCulture(
   culture : CultureInfo
) : InputLanguage;

Parameters

culture
A CultureInfo representing the locale whose input language is requested.

Return Value

An InputLanguage that represents the language for the specified culture, or a null reference (in Visual Basic Nothing) if none was found.

Remarks

If there is more than one input language for the culture, this method returns the first one in the language list.

Example [C#]

The following example changes the system input language.

When the user clicks on Button1, GetInstalledInputLanguages is called to retrieve an array of installed languages in the system. Then GetCulture is called for each InputLanguage in the array to get the name of the culture associated with the language. A ListBox is populated with these culture names.

When the user selects a new culture from the ListBox and clicks on Button2, the selected input language is set as the current input language.

This code assumes ListBox1, Button1 and Button2 have been instantiated.

[C#]

public void MyFromCulture2() {
   //Get the list of installed languages.
   InputLanguage[] myLanguages = InputLanguage.GetInstalledInputLanguages();

   for (int i=0; i<myLanguages.Length; i++)
      listBox1.InsertItem(i, myLanguages[i].GetCulture().EnglishName);

   //Print the current input language.
   InputLanguage myCurrentLanguage = InputLanguage.GetCurrentInputLanguage();
   textBox1.Text = "Current input language is: " + myCurrentLanguage.GetCulture().EnglishName + '\n';
}

public void SetNewCulture() {
   //Get the index number of the selected culture.
   int i = listBox1.SelectedIndex;

   //Get the list of installed languages.
   InputLanguage[] myLanguages = InputLanguage.GetInstalledInputLanguages();

   //Set the language for the selected culture as the current input language.
   InputLanguage.SetCurrentInputLanguage(myLanguages[i],0);

   //Print the new current input language.
   InputLanguage myCurrentLanguage = InputLanguage.GetCurrentInputLanguage();
   textBox1.Text += "New current input language is: " + myCurrentLanguage.GetCulture().EnglishName;
}

See Also

InputLanguage Class | InputLanguage Members | System.WinForms Namespace | CultureInfo | GetInstalledInputLanguages | GetCulture