2
I have a Panel
in a Form
wherever the Panel
is smaller than the Form
.
Here’s what I need to do: when the mouse is off Panel
the same must be closed as I could do it?
Note: I am trying to do this in Windows Form.
2
I have a Panel
in a Form
wherever the Panel
is smaller than the Form
.
Here’s what I need to do: when the mouse is off Panel
the same must be closed as I could do it?
Note: I am trying to do this in Windows Form.
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 mause on top of the label.
To get away from it you can do so:
private void Form1_MouseEnter(object sender, EventArgs e)
{
panel1.Visible = false;
}
Since you haven’t put in what you need for him to appear again I leave the answer so far.
It appears on mouse click!
1
Use the event MouseLeave
- it is fired whenever the mouse cursor gets off the control.
private void panel_MouseLeave(object sender, EventArgs e)
{
panel.Visible = false;
}
1
Click on the Panel you created in the form, press F4 (to open the properties panel of the control), in the properties panel of the control you will have the events button(The one that looks like lightning, goes to the "Mouseleave" event and gives two clicks (and has more things with mouse interactions that can help you).
Automatically, the code will 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 like this at the end:
private void panel1_MouseLeave(object sender, EventArgs e)
{
this.panel1.Visible = false;
}
Browser other questions tagged c# .net winforms
You are not signed in. Login or sign up in order to post.
Closed as? No way to close a Panel.
– Jéf Bueno
it should stay "invisible"
– Tozzi