简体   繁体   中英

How to change InputLanguage in .Net Windows Form?

I'm trying to change InputLanguage in C# Windows Form.

I want to change English to my language not to press any key on keyboard because I used to type my language with typing software.

That software is not change InputLanguage.CurrentInputLanguage.LayoutName .

if (InputLanguage.CurrentInputLanguage.LayoutName=="US")
{
    MessageBox.Show("IN US");
}
else
{
    MessageBox.Show("In Others");
}

I wrote that code but the software i used is not change LayoutName How can i do that?

According to MSDN to have to call the static method InputLanguage.CurrentInputLanguage to change it.

public void ChangeLanguage() {
    InputLanguage usLang = Getlanguage("US");
    InputLanguage.CurrentInputLanguage = usLang;
}

public Windows.Forms.InputLanguage GetLanguage(string language){
    language = language.ToLower();
    foreach (System.Windows.Forms.InputLanguage lang in System.Windows.Forms.InputLanguage.InstalledInputLanguages) {
        if (lang.LayoutName.ToLower() == language) {
            return lang;
        }
    }
    return null;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM