Mouse Enter/Leave event (global)
-
Hello, I have a minor problem. I have a Mouse Enter event declared for a Panel Control in c#. The Event is detected correctly when I enter the panel, but if I have other controls in that panel it does not work. So if I drag the mouse over a control from that panel, the mouse enter event is not activated. I hope I am explaining correctly. The ideea would be to get Activate the mouse enter event even if the mouse is entering a control from tha panel. Hope someone can help. Thanks
-
Hello, I have a minor problem. I have a Mouse Enter event declared for a Panel Control in c#. The Event is detected correctly when I enter the panel, but if I have other controls in that panel it does not work. So if I drag the mouse over a control from that panel, the mouse enter event is not activated. I hope I am explaining correctly. The ideea would be to get Activate the mouse enter event even if the mouse is entering a control from tha panel. Hope someone can help. Thanks
Two choices: 1. Make all the subcontrol mouseOver events point to the same event handler as the Panel MouseOver Event. 2. Do the same thing, dynamically. That is, handle the
ControlAdded
andControlRemoved
events of the panel and add/remove the handler on the fly e.g.void Panel1ControlAdded(object sender, System.Windows.Forms.ControlEventArgs e)
{
e.Control.MouseEnter += this.Panel1MouseEnter;
}void Panel1ControlRemoved(object sender, ControlEventArgs e)
{
e.Control.MouseEnter -= this.Panel1MouseEnter;
}However this second options relies on adding the handlers to the
ControlAdded
andControlRemoved
events before the sub controls are added.If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk