Solved

menustrip

Posted on 2006-06-14
5
382 Views
Last Modified: 2008-02-01
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
Comment
Question by:yanci1179
5 Comments
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 200 total points
ID: 16908263
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
 
LVL 2

Accepted Solution

by:
Anandavally_P earned 300 total points
ID: 16909126
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
 
LVL 11

Expert Comment

by:vo1d
ID: 16911787
why dont you just remove the submenues from the menuitem?
0
 

Author Comment

by:yanci1179
ID: 16911905
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
 
LVL 11

Expert Comment

by:vo1d
ID: 16912932
yes correct.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now