Close the panel when the mouse comes out

2

I have Panel in a Form any where Panel is less than Form .

I need to do the following: when the mouse leaves the top of Panel it should be closed how could I do this?

Note: I'm trying to do this in Windows Form.

    
asked by anonymous 08.12.2015 / 13:29

3 answers

2

You can use this:

private void panel1_MouseLeave(object sender, EventArgs e)
{
   panel1.Visible = false;
}

But if you have a label inside the panel it will disappear if you pass the label on the label.

To get away from it you can do this:

private void Form1_MouseEnter(object sender, EventArgs e)
{
    panel1.Visible = false;
}

As you did not put what you need for it to appear again I leave the answer here.

    
08.12.2015 / 13:44
1

Use the event MouseLeave - it is fired whenever the mouse cursor exits the control.

private void panel_MouseLeave(object sender, EventArgs e)
{
    panel.Visible = false;
}
    
08.12.2015 / 13:40
1

Click on the Panel that you created in the form, press F4 (to open the control's properties panel), in the control panel you will have the event button (the one that looks like lightning, goes to the event " MouseLeave "and give two clicks (and there are more things with mouse interactions that can help you).

The code will automatically be created:

private void panel1_MouseLeave(object sender, EventArgs e)  
{ 

}

To "close" the Panel, you can use the following code:

this.panel1.Visible = false;

Getting this way at the end:

private void panel1_MouseLeave(object sender, EventArgs e)  
{   
    this.panel1.Visible = false;  
}
    
08.12.2015 / 15:44