如何在特定事件处理程序中向上拦截鼠标 [英] How to intercept the mouse up in an specific event handler

查看:47
本文介绍了如何在特定事件处理程序中向上拦截鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< 2>
感谢您对我的问题的第一答案.但是,在mouseup事件中没有称为"handled"的布尔值,因此我仍然无法拦截mouse up事件,并且默认行为仍已完成.

设计一个特定的绘制对象对我来说太复杂了,因此,我仍然在等待任何简单的解决方案.谢谢.

< 1>
我设计了一个窗口应用程序,我的问题如下:

1.有一个treeview对象.
2.单击一个节点时,默认方式是该节点为
将其背景色更改为蓝色.
3.现在,当我点击
时,我想拥有我的特定功能 该节点,并且不会期望此节点的背景色发生变化
变成蓝色,所以我创建了一个事件处理程序:
treeview1.mouseup + =新的MouseEventHandler(treeview1_MouseUp);
4.这是我在事件处理程序中的特定语句.

现在,条件是在treeview mouseup事件之后是
执行后,该节点的背景色仍更改为蓝色,我的问题是如何拦截鼠标向上事件,并且不通过它
到系统以进行进一步处理"?

<2>
Thanks for first answer of my question. However, there is no bool called ''handled'' in mouseup event, so I still can not intercept the mouse up event, and the default behavior is still be done.

To design a specific draw object is too complicated to me, so, I am still waiting for any saimple solution for this. Thanks.

<1>
I design a window application, my question is below :

1. There is one treeview object.
2. When click on one node, the default way is that this node will be
changed its backcolor to be blue.
3. Now, I would like to have my specific function when mouse click on
the node, and would not expect the backcolor of this node is changed
to be blue, so I create an event handler :
treeview1.mouseup += new MouseEventHandler(treeview1_MouseUp);
4. And thre are my specific statements in the event handler.

Now, the condition is that after the treeview mouseup event is
executed, the backcolor of the node is still changed to be blue, my question is "How can I intercept the mouse up event, and do not pass it
to system for further process" ?

推荐答案

如果传入的eventargs有一个称为"handled"的布尔值,则可以将其设置为true.要确保您描述的默认行为不会发生,您可能必须为此创建一个所有者绘制的控件,或者,如果在调用处理程序之前就已经设置了颜色,则可以在事件处理程序中显式设置颜色.
If the eventargs passed in has a bool called ''handled'', you can turn it to true. This does not guarentee that the default behaviour your describe will not occur, you may have to create an owner drawn control for that, or perhaps you could explicitly set the color in your event handler, if it''s been set before your handler is called.


这篇关于如何在特定事件处理程序中向上拦截鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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