• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

menustrip

I am using the menustrip, when you click on it it automatically drops the menu.

How can I programatically close the menu that drops down when the menustrip is clicked?
0
yanci1179
Asked:
yanci1179
2 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Why not just disable it?...

This hack below works.  Handle the DropDownOpened() event.

I hope someone can show us a better way...   =\

        private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            Timer tmr = new Timer();
            tmr.Tag = sender;
            tmr.Interval = 100;
            tmr.Tick += new EventHandler(tmr_Tick);
            tmr.Start();
        }

        void tmr_Tick(object sender, EventArgs e)
        {
            Timer tmr = (Timer)sender;
            tmr.Stop();

            ToolStripMenuItem tsmi = (ToolStripMenuItem)tmr.Tag;
            tsmi.DropDown.Close();
        }
0
 
Anandavally_PCommented:
Hi,

Try this.

Suppose this is the menu strip sample

Menu1  Menu2
  SubMenu1
  SubMenu2

When we click on Menu1, SubMenu1 and SubMenu2 gets dropped down.
We can hide the drop down menu on the mouse leave function of Menu1.

private void menu1ToolStripMenuItem_MouseLeave(object sender, EventArgs e)
 {
            menu1ToolStripMenuItem.HideDropDown();
 }  

Thanks
Anandavally P  

0
 
vo1dCommented:
why dont you just remove the submenues from the menuitem?
0
 
yanci1179Author Commented:
thanks anandavally P, I used the Hide Drop Down even and it work perfectly.

If I remove them, I have to re-add them when I want them to see it. Right?

Thanks everybody, I really appreciate the help.

0
 
vo1dCommented:
yes correct.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now