/ Published in: C#
Just a snippet I like; this can be called on GotFocus or LostFocus of a field, and it *attempts* to set the input language to the desired language.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private void fixLanguage(string whichLanguage) { string useLanguage; switch (whichLanguage.ToLower() ) { case "chinese": useLanguage = "zh-CN"; break; default: useLanguage = "en-US"; break; } InputLanguage language = InputLanguage.CurrentInputLanguage; if (language.Culture.Name != useLanguage) { foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages) { if (lang.Culture.Name == useLanguage) { InputLanguage.CurrentInputLanguage = lang; } System.Console.WriteLine(lang.Culture.Name); } } if (language.Culture.Name == useLanguage) this.ImeMode = System.Windows.Forms.ImeMode.On; }