Solved

menustrip

Posted on 2006-06-14
5
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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