如何使回车键像点击按钮一样? [英] How do I make the enter key act like a button click?

查看:86
本文介绍了如何使回车键像点击按钮一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以帮助我,我正在努力解决特定的问题...


我有一个包含很多标签页的表单。在一个标签页上我有一个按钮

当用鼠标点击时会将项目添加到数据网格中。当一个

用户按下此按钮上的回车键时,我希望激活鼠标点击事件

,而是调用标签页的验证事件。 />

我明白这种行为部分是通过设计(接受按钮

等)但我没有为我的表单设置一个接受按钮(因为

许多标签页有多个按钮,所以接受或取消

按钮是不可行的。)


简而言之 - 对于喜欢键盘和鼠标的用户 - 我想要

按一下按钮,按下按钮点击按钮点击

鼠标。

我该怎么做?


(注意作为修复的一部分尝试,我已经尝试设置原因验证

为false我的按钮,以防止它调用标签页

验证事件,这不起作用 - 验证事件是

仍然触发)


非常感谢

Suzanne

解决方案

你真的不想这样做。我建议你创建一个sub /

具有你想要的功能,只需从按钮调用它,如果你

想通过鼠标点击来调用它给予控制你也可以做




-

OHM(Terry Burns)*使用以下方法给我发电子邮件*


Dim ch()As Char =" ufssz / cvsotAhsfbuTpmvujpotXjui / OFU" .ToCharArray()

For i As Int32 = 0 to ch .Length - 1

ch(i)= Convert.ToChar(Convert.ToInt16(ch(i)) - 1)

下一页

Process.Start(" mailto:"& New String(ch))

-

" SJ" <苏**************** @ yahoo.co.uk>在消息中写道

新闻:3d ************************* @ posting.google.co m ... < blockquote class =post_quotes>希望有人可以帮助我,我正在努力解决一个特定的问题...

我有一个包含许多标签页的表单。在一个标签页上我有一个按钮
当用鼠标点击时,会将项目添加到数据网格中。当
用户按下此按钮上的回车键时,我希望激活鼠标点击事件
,而是调用标签页的验证事件。

我理解这种行为部分是通过设计(接受按钮
等)但我没有为我的表单设置一个接受按钮(因为很多标签页有多个按钮所以接受或者取消
按钮不可行。

简而言之 - 对于喜欢键盘和鼠标的用户 - 我想按一下按钮上的输入键,就像一个按钮按钮单击使用
鼠标。
我该怎么做?

(注意作为部分尝试修复,我已经尝试将causevalidation设置为false)为我的按钮,以防止它调用标签页
验证事件,这不起作用 - 验证事件仍然被触发)

非常感谢
Suzanne



搞笑!

Dim ch()As Char =" ufssz / cvsotAhsfbuTpmvujpotXjui / OFU" .ToCharArray()
For i As Int32 = 0 to ch.Length - 1
ch(i)= Convert.ToChar (Convert.ToInt16(ch(i)) - 1)
下一步
Process.Start(" mailto:" &安培;新字符串(ch))



相反!


" Eric Sabine" < mopar41@mail_after_hot_not_before.com>在消息中写道

news:uz ************** @ tk2msftngp13.phx.gbl ...

搞笑!

Dim ch()As Char =" ufssz / cvsotAhsfbuTpmvujpotXjui / OFU" .ToCharArray()
For i As Int32 = 0 to ch.Length - 1
ch( i)= Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
下一步
Process.Start(" mailto:"& New String(ch))




Hope someone can help me out there I''m struggling with a particular
problem...

I have a form with many tab pages. On one tab page I''ve got a button
which when clicked with a mouse adds items into a datagrid. When a
user presses the enter key on this button I want the mouse click event
to be activated but instead the tab page''s validating event is called.

I understand that this behaviour is by partly by design (Accept button
etc) but I have not set an accept button for my form (because of the
many tab pages there is more than one button so an accept or a cancel
button is not viable).

In short - for my users who prefer the keyboard to the mouse - I want
an enter key press on a button to act like a button click using the
mouse.
How do I do this?

(Note as a part attempt to fix, I''ve tried setting causesvalidation
to false for my button to prevent it from calling the tab pages
validating event and this did not work - the validating event was
still triggered)

many thanks
Suzanne

解决方案

You really dont want to do this. I would suggest that you create a sub which
has the functionalty you want and simply call it from the button, if you
want to call it from a mouse click for a given control as well you can do
that also.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"SJ" <su****************@yahoo.co.uk> wrote in message
news:3d*************************@posting.google.co m...

Hope someone can help me out there I''m struggling with a particular
problem...

I have a form with many tab pages. On one tab page I''ve got a button
which when clicked with a mouse adds items into a datagrid. When a
user presses the enter key on this button I want the mouse click event
to be activated but instead the tab page''s validating event is called.

I understand that this behaviour is by partly by design (Accept button
etc) but I have not set an accept button for my form (because of the
many tab pages there is more than one button so an accept or a cancel
button is not viable).

In short - for my users who prefer the keyboard to the mouse - I want
an enter key press on a button to act like a button click using the
mouse.
How do I do this?

(Note as a part attempt to fix, I''ve tried setting causesvalidation
to false for my button to prevent it from calling the tab pages
validating event and this did not work - the validating event was
still triggered)

many thanks
Suzanne



Hilarious!

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))



Rather!

"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...

Hilarious!

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))




这篇关于如何使回车键像点击按钮一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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