关闭

多个文本框,都实现全选;光标进入就自动切换到五笔输入法

标签: 输入法textboxobjectstring
983人阅读 评论(0) 收藏 举报
分类:

step1:

        private void txt_Enter(object sender, EventArgs e)
        {
            ((TextBox)sender).ImeMode = System.Windows.Forms.ImeMode.On;

            string[] languagename = new string[] { "五笔", "拼音", "中文" };
            bool bResult = false;
            for (int i = 0; i < languagename.Length; i++)
            {
                foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
                {
                    if (lang.LayoutName.IndexOf(languagename[i]) >= 0)
                    {
                        InputLanguage.CurrentInputLanguage = lang;
                        bResult = true;
                        break;
                    }
                }

                if (bResult)
                    break;
            }
        }
 
        public void txt_KeyPress(object sender,KeyPressEventArgs e)
        {
            if (e.KeyChar == 1)
            {
                ((TextBox)sender).SelectAll();
            }
        }

step2:在form_load中添加

            txtSentence.Enter += new EventHandler(txt_Enter); // 光标进来时自动切换到五笔输入法
            txtRemark.Enter += new EventHandler(txt_Enter);

            txtSentence.KeyPress+=new KeyPressEventHandler(txt_KeyPress); // Ctrl + A 全选
            txtRemark.KeyPress += new KeyPressEventHandler(txt_KeyPress);  


 


 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2541972次
    • 积分:22155
    • 等级:
    • 排名:第316名
    • 原创:587篇
    • 转载:69篇
    • 译文:0篇
    • 评论:364条