I recently developed a software program and found that if there are multiple input controls in a window, when we change the input method of the first input control, the Input Method of other controls will not change (for example, some common software, only one switch for the input method). It is depressing to search online for a long time and finally find a solution.
Original article address: control the input method in the C # application and use C # to control the current Input Method
CodeAs follows (Put It In form_load ):
Code
If (Inputlanguage. defaultinputlanguage. layoutname. indexof ( " Keyboard " ) =- 1 && Inputlanguage. defaultinputlanguage. Culture. Name. Equals ( " Zh-CN " ))
{
Inputlanguage. currentinputlanguage = Inputlanguage. defaultinputlanguage;
}
Else
{
Foreach (Inputlanguage Lang In Inputlanguage. installedinputages)
{
If (Lang. Culture. Name. Equals ( " Zh-CN " ) && Lang. layoutname. indexof ( " Keyboard " ) =- 1 )
{
Inputlanguage. currentinputlanguage = Lang;
Break ;
}
}
}