shahzadq
asked on
vb .net Add a new menu item dynamically
In VB .Net 2005,
How can I dynamically setup a new menu item in the code?
I want to add a new item in the drop down menus, whenever a certain event happens in the program. I've tried to look through the objects myself, and I've searched around, I just can't seem to get anything clear...
Shahzad
How can I dynamically setup a new menu item in the code?
I want to add a new item in the drop down menus, whenever a certain event happens in the program. I've tried to look through the objects myself, and I've searched around, I just can't seem to get anything clear...
Shahzad
ASKER
I don't need a top level menu, I want a menu item on a drop down from the top. Next to File, I have Chat, underneath I want Window (As in Chat->Window). For each new form I instantiate, I want a Window 1, and window 2, and window 3 to appear in the menu that can pull up each form.
Any ideas how to pull that off?
I'm tinkering around with it right now, so many options, and so many errors...
Shahzad
Any ideas how to pull that off?
I'm tinkering around with it right now, so many options, and so many errors...
Shahzad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What namespace does WindowToolStripMenuItem come from?
(Sorry for the dumb question)
(Sorry for the dumb question)
ASKER
It doesn't seem to give me the "DropDownItems" option
It's actually ToolStripMenuItem from:
System.Windows.Forms.ToolS tripItem
If you have named the entry under "Chat", "Window", then the control ON THE FORM is called "WindowToolStripMenuItem".
You are probaly using the old .Net 1.1 menu system based on the MainMenu control.
In the IDE, look at your form with all the controls on it. Down BELOW the form you should see a placeholder for your Menu system.
+------------------------- --------+
| Form1 |
+------------------------- --------+
| |
| |
| |
| |
+------------------------- --------+
+--------------+ +--------------+
| MenuStrip1 | | MainMenu1 |
+--------------+ +--------------+
Which do you see? "MenuStrip1" or "MainMenu1"
System.Windows.Forms.ToolS
If you have named the entry under "Chat", "Window", then the control ON THE FORM is called "WindowToolStripMenuItem".
You are probaly using the old .Net 1.1 menu system based on the MainMenu control.
In the IDE, look at your form with all the controls on it. Down BELOW the form you should see a placeholder for your Menu system.
+-------------------------
| Form1 |
+-------------------------
| |
| |
| |
| |
+-------------------------
+--------------+ +--------------+
| MenuStrip1 | | MainMenu1 |
+--------------+ +--------------+
Which do you see? "MenuStrip1" or "MainMenu1"
Hey, Mikey, I see this comment:
>>I don't need a top level menu
That speaks of a ContextMenuStrip.
Bob
>>I don't need a top level menu
That speaks of a ContextMenuStrip.
Bob
I interpreted this line:
"I don't need a top level menu, I want a menu item on a drop down from the top."
As, I already have top level menus defined at design-time, and I want to add menu items below those existings.
His next statement supports that with:
"Next to File, I have Chat, underneath I want Window (As in Chat->Window)."
Finally, I interpret "Swan Lake Ballet" as "graceful but boring dancers that make loud noises on the floor when they leap about".
But I could be wrong... =)
"I don't need a top level menu, I want a menu item on a drop down from the top."
As, I already have top level menus defined at design-time, and I want to add menu items below those existings.
His next statement supports that with:
"Next to File, I have Chat, underneath I want Window (As in Chat->Window)."
Finally, I interpret "Swan Lake Ballet" as "graceful but boring dancers that make loud noises on the floor when they leap about".
But I could be wrong... =)
I agree with the Swan Lake assessment... Now "The Nutcracker" is a different story ;)
If this is an MDI form, with sub-forms, you can specify MdiList for the menu item.
Bob
If this is an MDI form, with sub-forms, you can specify MdiList for the menu item.
Bob
ASKER
+------------------------- --------+
| Form1 |
+------------------------- --------+
| |
| |
| |
| |
+------------------------- --------+
+--------------+ +--------------+
| MenuStrip1 | | MainMenu1 |
+--------------+ +--------------+
It says MenuStrip1
I'm using .net 2.0 with VS 2005
Let me try what you said and see what happens...
Shahzad
| Form1 |
+-------------------------
| |
| |
| |
| |
+-------------------------
+--------------+ +--------------+
| MenuStrip1 | | MainMenu1 |
+--------------+ +--------------+
It says MenuStrip1
I'm using .net 2.0 with VS 2005
Let me try what you said and see what happens...
Shahzad
ASKER
Thanks everyone...
2) What menu items are you adding?
Bob