Panel that changes size C#

Asked

Viewed 37 times

1

Good morning, I’m trying to do the following for my application Windows Forms C#. I have a Panel that by activating your event MouseHover, the panel expands its size and there inside the panel with larger size I want to add functionalities.

private void panel1_MouseHover(object sender, EventArgs e)
{
    panel1.Size = new Size(200, 250);
}

private void panel1_MouseLeave(object sender, EventArgs e)
{
    panel1.Size = new Size(25, 30);
}

When trying to add a checkedListBox in that panel I noticed that by hovering the mouse over the checkedListBox that is inside this panel, the event MouseLeave of panel is triggered. Could you help me with this problem? I’m not sure what to do.

1 answer

2


Change the event MouseLeave in this way:

private void panel1_MouseLeave(object sender, EventArgs e)
{
    if (panel1.GetChildAtPoint(panel1.PointToClient(MousePosition)) == null)
    {
         panel1.Size = new Size(25, 30);
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.