Windows Develop Bookmark and Share   
 index > Windows Forms General > Activate MenuStrip's ToolStripMenuItem's DropDownItems menu on MouseEnter (C#)
 

Activate MenuStrip's ToolStripMenuItem's DropDownItems menu on MouseEnter (C#)

I have a MenuStrip on a UserControl (like a listbox).

What I would like is on the MouseEnter event to the MenuStrip, to have the control behave as if the user had clicked on the appropriate item in the MenuStrip and display its menu of its DropDownItems.

I tried .Select() -ing the MenuStrip and the MenuStrip.Items[0]. Neither gets it into the DropDown menu display mode.

Essentially, I would like to bypass the first click and have the DropDownItems menu behavior start on MouseEnter.

Can anyone help?

Matt Heffron

Beckman Coulter, Inc.

Matt Heffron  Monday, October 08, 2007 10:47 PM

OK, on further digging I discovered the ShowDropDown() method on the ToolStripMenuItem.

If Isimulate aHitTest on the mouse position in the MouseEnter handler I can activate a DropDown.

HOWEVER, how can I get it into the "tracking" mode if there is no ToolStripMenuItem at the position where the MouseEnter occurs?

Will I need to track MouseMove until it is over a ToolStripMenuItem, ShowDropDown() the item and then "get out of the way" and let the MenuStrip just continue with its normal behavior? (Until the next MouseEnter?)

What about "unwinding" all of this when the mouse leaves the MenuStrip or one of the DropMenus, so the other controls on the form work as expected?

Matt Heffron

Beckman Coulter, Inc.

Matt Heffron  Monday, October 08, 2007 11:02 PM

You can use google to search for other answers

Custom Search

More Threads

• How Can I Read ActiveSheet From Excel Document
• Capturing and printing a portion of a form...
• KeyDown/KeyPress/KeyUp wishes
• listview gridline problem..
• What are .pdb files
• Application.AddMessageFilter Query
• Modal Form without ShowDialog
• MAJOR Bug? In Webbrowser Control
• Creating MDI Applications - MSDN documentation
• Event and asynchronous operation