Hi Mojo,
Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you do not want the MouseLeave
event was fired when the mouse enter the control on the panel, by default
this will be fired.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
I think you can derived a cusomized Panel and override the OnMouseMove
event.
Here I write a sample for you.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Panel1 = New MyPanel
Dim textBox1 As New TextBox
Dim label1 As New Label
' Initialize the Panel control.
panel1.Location = New Point(56, 72)
panel1.Size = New Size(264, 152)
' Set the Borderstyle for the Panel to three-dimensional.
panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
' Initialize the Label and TextBox controls.
label1.Location = New Point(16, 16)
label1.Text = "label1"
label1.Size = New Size(104, 16)
textBox1.Location = New Point(16, 32)
textBox1.Text = ""
textBox1.Size = New Size(152, 20)
' Add the Panel control to the form.
Me.Controls.Add(panel1)
' Add the Label and TextBox controls to the Panel.
panel1.Controls.Add(label1)
panel1.Controls.Add(textBox1)
End Sub
Private Sub Panel1_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Panel1.MouseLeave
MsgBox("Mouse Leave")
End Sub
End Class
Public Class MyPanel
Inherits System.Windows.Forms.Panel
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
Dim clientPoint As Point = PointToClient(Cursor.Position)
If Me.DisplayRectangle.Contains(clientPoint) Then
Return
End If
MyBase.OnMouseLeave(e)
End Sub
End Class
Does this answer your question?
If you have any concern on this issue, please post here.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.