1、窗体加载时,获取当前操作系统中已经存在的输入法(如下)
//获取系统中已经存在的输入法
InputLanguageCollection ilCollection=InputLanguage.InstalledInputLanguages;
//将输入法的名称都放到comboBox中
foreach (InputLanguage il in ilCollection)
{
this.comboBox1.Items.Add(il.LayoutName);
}
this.comboBox1..Text = InputLanguage.InstalledInputLanguages[parameter.InputMethod].LayoutName;//parameter.InputMethod为数据库中保存的默认输入法的值(int型)
2、//获取选定的输入法
InputLanguage il = InputLanguage.InstalledInputLanguages[this.comboBox1.SelectedIndex];
//设置当前输入法
InputLanguage.CurrentInputLanguage = il;
3、在应用程序系统登录时
//获取选定的输入法
InputLanguage il = InputLanguage.InstalledInputLanguages[parameter.InputMethod];
//设置当前输入法
InputLanguage.CurrentInputLanguage = il;
本文介绍了如何使用C#在Windows应用程序中实现输入法的自动切换。具体包括:1. 在窗体加载时获取系统中存在的所有输入法并显示在ComboBox中;2. 通过ComboBox选择特定输入法并设置为当前输入法;3. 在应用程序登录时根据预设参数自动设置默认输入法。
2584

被折叠的 条评论
为什么被折叠?



