I have a form that consists of only a TableLayoutPanel (which fills the entire form) containing a vertical stack of buttons. The resulting app is used in conjunction with another app. What I would like is to have the vb app do something when the mouse enters the form. Unfortunately, all mouse enter/leave events are trapped by the panel or the buttons.
As a quick test I created a form with a tablelayoutpanel (docked to fill the form) containing one button. I added the following code:
Private Sub Form1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles MyBase.MouseEnter
Debug.WriteLine("enter form")
End Sub
Private Sub Form1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles MyBase.MouseLeave
Debug.WriteLine("leave form")
End Sub
Private Sub TableLayoutPanel1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles TableLayoutPanel1.MouseEnter
Debug.WriteLine("enter panel")
End Sub
Private Sub TableLayoutPanel1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles TableLayoutPanel1.MouseLeave
Debug.WriteLine("leave panel")
End Sub
Private Sub Button1_MouseEnter(sender As System.Object, e As System.EventArgs) Handles Button1.MouseEnter
Debug.WriteLine("enter button")
End Sub
Private Sub Button1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles Button1.MouseLeave
Debug.WriteLine("leave button")
End Sub
There was no way of moving the mouse around that caused the form's mouse enter or leave events to fire. Is there anything (perhaps similar to KeyPreview) that lets me see the mouse enter/leave events at the form level? I could always add a common Mouse_Enter event to each button (all buttons are created at runtime) but this seems like a crude way to do it.