Home All Groups Group Topic Archive Search About

How to open menu programmatically

Author
1 Jul 2009 3:44 PM
Gregory K
I am using Windows Forms, C#, VS2005.
I am developing an assistant that will guide a user through the application.
At some point I need to open specific menus just like the user would by
moving a mouse over it (for example, open File submenu in the Main menu).
How can I do it from the code?
Gregory
Author
1 Jul 2009 8:42 PM
miher
"Gregory K" <Grego***@discussions.microsoft.com> az alábbiakat írta a
következő üzenetben
news:A06A73D7-42C0-4578-BB4B-BFD9AD819C25@microsoft.com...
> I am using Windows Forms, C#, VS2005.
> I am developing an assistant that will guide a user through the
> application.
> At some point I need to open specific menus just like the user would by
> moving a mouse over it (for example, open File submenu in the Main menu).
> How can I do it from the code?
> Gregory

Hi,

Try using the ShowDropDown method.
(
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripdropdownitem.showdropdown.aspx )

Hope You find this useful.
-Zsolt
Are all your drivers up to date? click for free checkup

Author
2 Jul 2009 1:56 PM
Gregory K
Thank you. This is exactly what I need.
Gregory
Author
2 Jul 2009 3:01 PM
Gregory K
I have another question. How can I programmatically show the context menu of
a TreeNode? I tried node.ContextMenuStrip.Show() but it shows the menu in a
wrong location. I can determine absolute location of the node at run time and
use it as a parameter to Show() but it's not trivial. I hope there is a
better way.
Gregory
Author
2 Jul 2009 5:36 PM
Jeff Johnson
"Gregory K" <Grego***@discussions.microsoft.com> wrote in message
news:1E1CED95-84D1-4C2D-977E-15A1BB5DB5C5@microsoft.com...

>I have another question. How can I programmatically show the context menu
>of
> a TreeNode? I tried node.ContextMenuStrip.Show() but it shows the menu in
> a
> wrong location. I can determine absolute location of the node at run time
> and
> use it as a parameter to Show() but it's not trivial. I hope there is a
> better way.

Nope, that's the only way. Why do you say it's not trivial, though? Just use
the Show() overload that takes a Control and a Point, and use the parent
tree view as the Control and extract a Point from the node's Bounds
property.

Bookmark and Share