Visual Basic .NET Forums    

Go Back   Visual Basic .NET Forums > Components & Controls > Menus & Toolbars

VB.NET Forums Newsletter Signup:
Email address:


Menus & Toolbars Discussion of menu and toolbar components

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-28-2008, 2:24 PM
Zexor's Avatar
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Posts: 11
Reputation: 4
Zexor is on a distinguished programming path ahead
Question How to Merge 2 ContextMenuStrips?

I have 2 ContextMenuStrips already created. cmsMenu1 and cmsMenu2. Is there a way to make a cmsMenu3 that is cmsMenu1 + cmsMenu2?

I know i can do this with a dropdown menu

Code:
cmsMenu3.Items.Clear()
cmsMenu3.Items.Add("Menu 1")
DirectCast(cmsMenu3.Items(0), ToolStripMenuItem).DropDown = cmsMenu1
cmsMenu3.Items.Add("Menu 2")
DirectCast(cmsMenu3.Items(1), ToolStripMenuItem).DropDown = cmsMenu2
but can it be done without the dropdown and have both cmsMenu1 and cmsMenu2 straight down in the first level?

Last edited by Zexor; 11-28-2008 at 9:15 PM.
Reply With Quote
  #2 (permalink)  
Old 11-30-2008, 5:45 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 8,138
Reputation: 876
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

With ToolStripManager you can Merge one strip to another, but the source strip will not work standalone after that until you RevertMerge. This is similar to doing Items.Add/AddRange with another strips Items, except such merge you can't "revert" as easily. The reason the source strip is not available until merge is reverted is because a menu item object can only have one parent.
__________________
See this thread about how to use forum markup codes for code blocks etc (present the problem/post properly )
Some useful links: Learning videoes, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ


DR. WEIR: Download it to a non-networked, firewalled computer.
TECHNICIAN: Yes, ma'am.
Reply With Quote
  #3 (permalink)  
Old 11-30-2008, 6:18 PM
Zexor's Avatar
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Posts: 11
Reputation: 4
Zexor is on a distinguished programming path ahead
Default Merge

ToolStripManager make cmsMenu3 works but in the process losing cmsMenu1 and 2. I need all 3 strips at the same time tho. Right now i am making cmsMenu3 by combining the code used to make menu1 and 2. I just thought there would be an easier way of doing it.

Couldn't i just do an addrange and copy cmsMenu1 to cmsMenu3 then do another addrange and copy cmsMenu2 to cmsMenu3?
Reply With Quote
  #4 (permalink)  
Old 12-01-2008, 5:42 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 8,138
Reputation: 876
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

No, as I said Merge/Add will move the menu item object because it can only be in one menustrip at a given time.
__________________
See this thread about how to use forum markup codes for code blocks etc (present the problem/post properly )
Some useful links: Learning videoes, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ


DR. WEIR: Download it to a non-networked, firewalled computer.
TECHNICIAN: Yes, ma'am.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 5:25 AM.




Click to advertise here

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
For advertising opportunities click here.