如何创建鼠标上移事件的控制 [英] How to Create A mouse Up Event Of Control

查看:71
本文介绍了如何创建鼠标上移事件的控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友.

我想为表单中存在的所有控件创建mouse up事件.
我的目的是当鼠标指针悬停在控件上时,它们将显示该控件的名称.

解决方案

您所说的是包含控件的窗体.因此,假设您正在使用Windows窗体.

每当释放鼠标按钮时,就会触发MouseUp.根据您告诉我们的内容,您想改为使用MouseHover事件.

通常,您必须创建一个将控件作为参数的方法,并使其输出控件的名称.然后,您可以将该方法订阅每个控件的MouseHover事件.

全局鼠标挂钩 [ 解决方案

You speak of a Form containing controls. So let''s assume you''re using Windows Forms.

MouseUp fires whenever a mouse button is released. From what you tell us, you want to use the MouseHover event instead.

Normally, you would have to create a method that takes a control as an argument and make it output the control''s name. Then you would subscribe that method to every control''s MouseHover event.

Or maybe a
global mouse hook[^] is what you''re looking for.


Hi
Please let me know in which technology you are talking about? is ASP.NET or Windows Forms? any way i will suggest you in both the cases:

Windows Forms
In Windows every control is Inherited from System.Windows.Forms.Control class and this control class has many mouse events MouseHover and MouseUp is the couple of events which you needed as per your Question.

Now you need to Implement one MouseHover Method/Handler and bind this method for all of your controls so that every controls mouse Hover event raises to the same method and using sender object you can get the current mouse over control and fetch the respective name and show the tooltip or what ever you want..

Web Application
Same as Windows Forms but here we have another option which is best suitable and traditional method is to use CSS + Javascript and recently we have a beautiful Tool called JQuery..


这篇关于如何创建鼠标上移事件的控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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