在文本框中输入关键行为 [英] Enter Key Behavior in Text Box

查看:60
本文介绍了在文本框中输入关键行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个访问表单,其中有一个带有2个标签的标签控件。


每个标签都有一个文本box(比如text1& text2)


每个标签还有一个命令按钮(button1& button2)


我在找什么for是当用户在文本框中按Enter键时,则调用button_click事件。 (在两个选项卡中均为true)


我尝试将按钮设置为default = true,也尝试将代码放在文本框的Exit属性中但没有运气。


我不想从表单的设计视图或Access Options中更改Enter Key属性,因为正在使用该应用程序的其他用户可能没有更改它,也不会能够工作。


请建议。


谢谢。

解决方案

令我惊讶的是,keypress / keydown事件也无法跟踪Enter键的ascii代码,也没有做任何事情。该代码适用于其他键..


您确定无法识别回车键码,Yaaara?我将以下内容放在名为Country的文本框的keydown事件中进行检查,并在按下回车键时按预期工作:

展开 | 选择 | Wrap | 行号

斯图尔特的代码非常标准。也许我们需要查看您尝试过的实际代码。


当然,您只能将一个命令按钮指定为给定表单的默认值。一个问题确实浮现在脑海中;只需单击其中一个命令按钮就会发生相应的事件,这些按钮应该做什么?


欢迎来到 Bytes


Linq ; 0)>


Hi,

I have a access form on which there is a tab control with 2 tabs.

each tab has a text box (lets say text1 & text2)

each tab also has a command button (button1 & button2)

What I am looking for is when the user presses the Enter key in a text box, then the button_click event to be called. (true in both the tabs)

I have tried making the buttons to default=true, also tried putting the code in the Exit property of the text box but no luck.

I don''t want to change the Enter Key property from the form''s design view or from Access Options as the other users who are using the app may not have changed it and would not be able to work.

Pls suggest.

Thanks.

解决方案

To my surprise, the keypress/keydown event fails to track the Enter key''s ascii code as well and does nothing. The code works well for other keys..


Are you sure the enter keycode is not being recognised, Yaaara? I placed the following in the keydown event of a textbox called Country to check and it worked as expected when the enter key was pressed:

Expand|Select|Wrap|Line Numbers


Stewart''s code is pretty standard stuff. Perhaps we need to look at the actual code you''ve tried.

You can, of course, only assign one command button as the default for a given form. One question does come to mind; does the appropriate event occur when you simply click on one of these command buttons, and what are these buttons supposed to do?

Welcome to Bytes!

Linq ;0)>


这篇关于在文本框中输入关键行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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