I did an application to enter chinese pinyin and hanzi in a database. That means that the operator have to switch constantly between "Pinyinput" and "sogou input" with ctrl+shift There is a way to make the IME change automaticall when a textbox is selected? I mean, not switch the keyboard layout, just the input method of the same keyboard layout
views:
486answers:
1
                +2 
                A: 
                
                
              try this, I'm not sure about the name of the languages, try to debug it and get the right name if it didn't work.
public void ToPinyinput()
        {
                string CName= "";
                foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
                {
                        CName = lang.Culture.EnglishName.ToString();
                        if(CName.StartsWith("Pinyinput"))
                        {
                                InputLanguage.CurrentInputLanguage = lang;
                        }
                }
        }
public void Tosogou()
        {
                string CName= "";
                foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
                {
                        CName = lang.Culture.EnglishName.ToString();
                        if(CName.StartsWith("sogou"))
                        {
                                InputLanguage.CurrentInputLanguage = lang;
                        }
                }
        }
if it didn't work, you need to change the following line to the correct lang name:
CName.StartsWith("langName")
                  Wael Dalloul
                   2009-09-30 08:33:43
                
              this code is working, thank you! But it can only switch between languages, not between input methods in the same language (culture)
                  Magnetic_dud
                   2009-09-30 13:23:31
                change CName = lang.Culture.EnglishName.ToString(); with CName = lang.LayoutName.ToString(); and the code is perfect! Thank you!!!!
                  Magnetic_dud
                   2009-09-30 13:27:09