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

前端之家收集整理的这篇文章主要介绍了[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.f2er.com/vb/264058.html

猜你在找的VB相关文章