单击按钮时如何防止单击事件 [英] How to Prevent the Click Event when a Button is Clicked

查看:65
本文介绍了单击按钮时如何防止单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击一个按钮时,我不希望点击事件发生。这是

可能吗?


事实上,我真正想要的是能够拦截点击

事件,执行一些操作,然后阻止点击通过

到按钮。


任何帮助或建议非常感谢。

Charles

When I click a button I don''t want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through
to the button.

Any help or suggestions much appreciated.

Charles

推荐答案

为什么不从Click事件中移除或调整代码?


按钮本身不会做任何事情。


-

Klaus H. Probst,MVP
http://www.vbbox.com/


" ; Charles Law < BL *** @ nowhere.com>在消息中写道

news:eU ************** @ TK2MSFTNGP11.phx.gbl ...
Why don''t you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
当我点击一个按钮时我不希望点击事件发生。这是否可能?

事实上,我真正想要的是能够拦截点击事件,执行一些操作,然后阻止点击通过
到按钮。

任何帮助或建议非常感谢。

Charles
When I click a button I don''t want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing through to the button.

Any help or suggestions much appreciated.

Charles



嗨Klaus


我实际上有很多按钮,文本框和下拉菜单,等等我想要做的
这个。为了调整每一个代码的代码将会很乏味和重复。


我真的在寻找原理,以便我可以将它应用到其他类型

的控制权。例如,我还想阻止

下拉下拉,并且当点击

时阻止按钮显示为按下。简而言之,我希望控件表现得像从未得到过

点击/鼠标按下事件。


Charles

Klaus H. Probst <我们******* @ vbbox.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
Hi Klaus

I actually have a lot of buttons, and text boxes, and dropdowns, and so on
that I want to do this for. To condition the code in every single one would
be tedious and repetitive.

I am really looking for the principle so that I can apply it to other types
of control as well. For example, I also want to prevent a dropdown from
dropping down, and prevent the button from appearing depressed when it is
clicked. In a nutshell, I want the control to behave like it never got the
click / mouse down event.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
为什么不穿你只是删除或调整Click事件中的代码吗?

按钮本身不会做什么。

-
Klaus H. Probst, MVP
http://www.vbbox.com/

查尔斯劳 < BL *** @ nowhere.com>在消息中写道
新闻:eU ************** @ TK2MSFTNGP11.phx.gbl ...
Why don''t you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
当我点击一个按钮时,我不知道我想要点击事件来触发。这是否可能?

实际上,我真正想要的是能够拦截点击事件,执行一些操作,然后阻止点击传递
When I click a button I don''t want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing


通过

到按钮。

任何帮助或建议非常感谢。

Charles
to the button.

Any help or suggestions much appreciated.

Charles




这是可能的,你可以简单地继承控件本身和

make它可以做你想做的任何事情。


例如,你可以在OnClick方法中加入一些代码,这样你的东西就可以了b / b
并防止事情冒泡到容器。


但是假设你从那里开始 - 现在代码很难改装

,特别是如果你有很多。

-

Klaus H. Probst,MVP
http://www.vbbox.com/

" Charles Law" < BL *** @ nowhere.com>在消息中写道

新闻:e#************* @ tk2msftngp13.phx.gbl ...
Well that''s possible, you can simply inherit from the control itself and
make it do anything you want.

For example, you could put some code in the OnClick method and so your stuff
there and prevent things from bubbling up to the container.

But that assumes that you started there - it''s going to be hard to retrofit
to your existing code, especially if you have a lot of it.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Charles Law" <bl***@nowhere.com> wrote in message
news:e#*************@tk2msftngp13.phx.gbl...
嗨克劳斯

我实际上有很多按钮,文本框和下拉菜单,等等我想要这样做。为了调整每一个
中的代码将是乏味和重复的。

我真的在寻找原理,以便我可以将它应用于其他
类型的控制。例如,我还想阻止下拉下拉,并防止按钮在点击时显示为按下状态。简而言之,我希望控件表现得像从未有过点击/鼠标按下事件。

Charles

" Klaus H. Probst" <我们******* @ vbbox.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
Hi Klaus

I actually have a lot of buttons, and text boxes, and dropdowns, and so on
that I want to do this for. To condition the code in every single one would be tedious and repetitive.

I am really looking for the principle so that I can apply it to other types of control as well. For example, I also want to prevent a dropdown from
dropping down, and prevent the button from appearing depressed when it is
clicked. In a nutshell, I want the control to behave like it never got the
click / mouse down event.

Charles
"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
为什么不是你只是删除或调整Click事件中的代码?

按钮本身不会做什么。

-
Klaus H. Probst,MVP http://www.vbbox.com/

查尔斯劳 < BL *** @ nowhere.com>在消息中写道
新闻:eU ************** @ TK2MSFTNGP11.phx.gbl ...
Why don''t you just remove or condition the code from the Click event?

The button will do nothing by itself.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"Charles Law" <bl***@nowhere.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
当我点击一个按钮时,我不知道我想要点击事件来触发。这是否可能?

实际上,我真正想要的是能够拦截点击事件,执行一些操作,然后阻止点击传递
When I click a button I don''t want the click event to fire. Is this
possible?

In fact, what I would really like is to be able to intercept the click
event, perform some action, and then prevent the click from passing


通过

到按钮。

任何帮助或建议非常感谢。

Charles
to the button.

Any help or suggestions much appreciated.

Charles





这篇关于单击按钮时如何防止单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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