文字框导航 [英] Textbox navigation

查看:72
本文介绍了文字框导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用键盘按键而不是通过鼠标单击来将焦点从一个文本框移到另一个文本框.所以我编写了代码,但是它不起作用.它显示了一些错误.代码是:

I want to get focus from one text box to another using keyboard keys not by mouse click .so I wrote the code but it doesn''t work. It shows some error. The code is:

private void keypressHandler(object sender, KeyPressEventArgs e) {
if (e.KeyChar == Keys.Enter) {
SendKeys.SendWait("{TAB}");
}
}  


我得到的错误是:
operator ==不能应用于类型为"char"和System.windows.forms.keys的操作数.

如何清除错误?如果是错误的方法,请提供正确的代码.


The error I get is:
operator==cannot be applied to operands of type ''char'' and System.windows.forms.keys"

How can I remove the error? If it''s a wrong way then give correct code.

推荐答案

而不是``e.KeyChar == Keys.Enter"尝试:
e.KeyChar == 11

有关详情,请参见此页: KeyChar值 [
Instead of ''e.KeyChar == Keys.Enter'' try:
e.KeyChar == 11

See this page for details: KeyChar values[^]

Thus, something like:
if (e.KeyChar.Equals(Convert.ToChar(11)))
{
    SendKeys.SendWait("{TAB}");
}


这篇关于文字框导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆