Enter/Leave events on a panel
Why does'nt the enter and leave events fire when I click on a panel?
InitializeComponent()
{
//do some stuf
this.panel1.Enter += new System.EventHandler(this.panel1_Enter);
//do some more stuff
}
private void panel1_Enter(object sender, System.EventArgs e)
{
//Do some important stuff
}
Anyone have any sugestions to hov i can fix it? Idont think I can use the onclick event... because then i cant get the same functionalitay as the leave metod would give me
thanks
the Enter and leave events of a panel are only fired when you have a control inside of a panel and *THAT* control receives focus...Ken getz explained it in another post i had where i was trying to do essentially the exact same thing. essentially if you have controls inside that panel, as soon as one of them receives an Enter your panel will raise Enter as well.
Hope this helps.
-Randy
<a href="http://www.windowsforms.com/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=653">Here's</a> the link to the entire thread. As in that thread, I don't really understand how a user would trigger the Enter or Leave events if the Panel control doesn't contain any controls, 'cause there's nothing to click on inside the Panel to get the focus, and the panel itself can't get the focus. But clearly, it's an issue, if it's come up twice in such short notice!
well, the reasoning i had was because i had a panel that i am tracking mouse clicks on, if the mouse click is in a certain position (an image that is drawn in the OnPaint, essentially a [+/-]) image i needed the enter/leave to be fired..but i've moved on and we're not using that particular control anymore, so that was my workaround ;)