setLanguage in WinForms


/ Published in: C#
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. private void fixLanguage(string whichLanguage)
  2. {
  3. string useLanguage;
  4. switch (whichLanguage.ToLower() )
  5. {
  6. case "chinese":
  7. useLanguage = "zh-CN";
  8. break;
  9. default:
  10. useLanguage = "en-US";
  11. break;
  12. }
  13. InputLanguage language = InputLanguage.CurrentInputLanguage;
  14. if (language.Culture.Name != useLanguage)
  15. {
  16. foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
  17. {
  18. if (lang.Culture.Name == useLanguage)
  19. {
  20. InputLanguage.CurrentInputLanguage = lang;
  21. }
  22. System.Console.WriteLine(lang.Culture.Name);
  23. }
  24. }
  25. if (language.Culture.Name == useLanguage)
  26. this.ImeMode = System.Windows.Forms.ImeMode.On;
  27. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.