Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Enter/Leave events on a panel
 

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 
MigrationUser 1  Monday, March 10, 2003 1:33 PM
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
MigrationUser 1  Tuesday, March 11, 2003 7:08 AM
<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! 
MigrationUser 1  Tuesday, March 11, 2003 9:05 AM
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 ;)
MigrationUser 1  Tuesday, March 11, 2003 10:49 AM

You can use google to search for other answers

Custom Search

More Threads

• Capture Enter key
• Notepad help
• Designer loader did not provide a root component, but did not indicate why
• Create and edit a TabPage as a stand alone object
• Extensibility DTE Object Unavailable (error) in WinForms Design
• Change label text when dropping on hosted designer
• finding the position of labels in the propertygrid
• How to hide "greyed" properties in Properties explorer
• How do I Open a new form from a button click event?
• ToolStrip Parent