微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

[VB.NET]我想判断光标是否在A控件上,在就触发一个事件,没在也触发一个事件,请各位高人想个办法,在线等待

我想判断光标是否在A控件上,在就触发一个事件,没在也触发一个事件,请各位高人想个办法,在线等待 我想判断光标是否在A控件上,在线等待 __________________________________________________________________________ LostFocus和GotFocus __________________________________________________________________________ private void button1_Click(object sender,EventArgs e) { Timer timer = new Timer(); timer.Interval = 200; timer.Tick += new EventHandler(timer_Tick); timer.Start(); } void timer_Tick(object sender,EventArgs e) { Control tmp = this.GetChildAtPoint(this.PointToClient(Cursor.Position)); if (tmp != null) { Console.WriteLine( "鼠标在控件{0}之上. ",tmp); } } __________________________________________________________________________ VB.NET代码: Private Sub button1_Click(ByVal sender As Object,ByVal e As EventArgs) Dim timer As New Timer timer.Interval = 200 AddHandler timer.Tick,New EventHandler(AddressOf Me.timer_Tick) timer.Start End Sub Private Sub timer_Tick(ByVal sender As Object,ByVal e As EventArgs) Dim tmp As Control = MyBase.GetChildAtPoint(MyBase.PointToClient(Cursor.Position)) If (Not tmp Is nothing) Then Console.WriteLine( "鼠标在控件{0}之上. ",tmp) End If End Sub __________________________________________________________________________

原文地址:https://www.jb51.cc/vb/264058.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐