Solved

menustrip

Posted on 2006-06-14
5
407 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
InputLanguage 1 33
Input parameteres to DragOver 2 19
linq, c# 8 22
C# Linq Select From List 3 8
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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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