Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a panel in which I have several buttons.For ex:`btnProduct`,`btnSale`. I have two another panels for example `productSubMenuPanel` and `salesSubMenuPanel`.

When mouse hover over the `btnProduct` it should make visible the `productSubMenuPanel` and it (`productSubMenuPanel`) should not hide until the user click on any buttons present in `productSubMenuPanel`. After clicking the button present inside `productSubMenuPanel` then `productSubMenuPane` should be hided.

When mouse leaves the `btnProduct` then `productSubMenuPanel` should be hided. Similarly, when mouse leaves the `productSubMenuPanel` without clicking any button present inside this panel then `productSubMenuPanel` should be hided.

What I have tried:

private void btnProduct_MouseEnter(object sender, EventArgs e)
       {
           productSubMenuPanel.Visible = true;
       }

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

       private void productSubMenuPanel_MouseEnter(object sender, EventArgs e)
       {
           productSubMenuPanel.Visible = true;

       }

       private void productSubMenuPanel_MouseLeave(object sender, EventArgs e)
       {
          productSubMenuPanel.Visible = false;

       }

       private void btnSale_MouseEnter(object sender, EventArgs e)
       {
           salesSubmenuPanel.Visible = true;
       }

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

       private void salesSubmenuPanel_MouseEnter(object sender, EventArgs e)
       {
           salesSubmenuPanel.Visible = true;
       }
       private void salesSubmenuPanel_MouseLeave(object sender, EventArgs e)
       {
           salesSubmenuPanel.Visible = false;
       }
Posted
Updated 15-Nov-19 1:45am

1 solution

The Mouse enter event won't fire if the panel is not visible:
private void productSubMenuPanel_MouseEnter(object sender, EventArgs e)
{
    productSubMenuPanel.Visible = true;
}
 
Share this answer
 
Comments
Member 14649908 15-Nov-19 8:03am    
please write code for the above functionality.Thnaks in advance.
Kats2512 15-Nov-19 9:03am    
No one on this forum is going to write code for you, you are not paying for a support service here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900