Link to home
Start Free TrialLog in
Avatar of Richard Payne
Richard PayneFlag for Bulgaria

asked on

C# top menu, toolstripmenuitem, how to stop closing as I need to check several option

C#, VS2015. related to top menu where I have several toolstripmenuitem with list of option that I like to check thro, but I need to stop autohide.
I could not find closing event which enable to cancel closing. I do not see autohide to set false in property.

Please provide C# code example how to keep menu from closing, while checking until I finish with it (by clicking outside the pull down menu or escape key)
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Payne

ASKER

There is no formclosing in the list of the properties on pulled down menu item, it missing.  It just has formclosed.

R.
This is MenuStrip object
It has DropItemClosed but no DropItemClosing event.
Avatar of William Domenz
If you add these events to your code - you can keep the menu open till the mouse leaves:

  bool MouseIn = false;

        private void contextMenuStrip1_Closing( object sender , ToolStripDropDownClosingEventArgs e )
        {
            if ( MouseIn )
            {
                e.Cancel = true;
                return;
            }
                
        }

        private void contextMenuStrip1_MouseEnter( object sender , EventArgs e )
        {
            MouseIn = true;
        }

        private void contextMenuStrip1_MouseLeave( object sender , EventArgs e )
        {
            MouseIn = false;
        }

Open in new window

Wiliams

Thank for reply but there is no closing properties for that menulist..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank for trying no solution, so I took other way,  but grateful for your response.