|
-
Mar 13th, 2009, 08:32 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] MenuStrip Question
hi all,
i have an mdi form with a menustrip.. File Edit View
i have an mdi child with a menustrip... Tools Actions
i want to be able to add the Tools Actions to the menu in my mdi and not show them in my mdichild.
is that possible?
thanks.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 14th, 2009, 04:57 AM
#2
Re: [2005] MenuStrip Question
Hey,
If I have understood you correctly, then yes, this is possible, but you are going to need to handle some of this yourself, as I am not aware of a way of doing it automatically.
For instance, in the load event of your child form, you could have something like this:
Code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim parentForm As Form1
parentForm = Me.MdiParent
Dim newMenuItem As New ToolStripMenuItem
newMenuItem.Text = "Test"
AddHandler newMenuItem.Click, AddressOf newMenuItem_Click
parentForm.MenuStrip1.Items.Add(newMenuItem)
End Sub
Private Sub newMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show("New Item Clicked")
End Sub
Depending on how you are wanting to do things, you may need to remove this menu item again when the child form closes.
Thinking about it, you may be able to create the menu on the child form at design time, then programmatically loop through them at runtime and add them to the parent form, and then hide the menu on the child form. I will go and give that a try.
Hope that helps!!
Gary
-
Mar 14th, 2009, 05:03 AM
#3
Re: [2005] MenuStrip Question
Hey,
This seems to work:
Code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim parentForm As Form1
parentForm = Me.MdiParent
parentForm.parentMenu.Items.AddRange(Me.childMenu.Items)
Me.childMenu.Visible = False
End Sub
Hope that helps!!
Gary
-
Mar 14th, 2009, 06:06 AM
#4
Re: [2005] MenuStrip Question
Can't you use Merging for that? It can do it automatically.
EDIT
You don't need to even set any properties, it works automatically.
Create a main form with IsMdiParent = True. Put a MenuStrip on it with the menus "File", "Edit" and "View".
Create a child form with a MenuStrip with the menus "Tools" and "Actions".
Use a button or something to create your mdi child, and the Tools and Actions menus should be merged into the main forms MenuStrip, besides, File, Edit, View.
vb.net Code:
Dim f As New FormMdiChild f.MdiParent = Me f.Show()
Last edited by NickThissen; Mar 14th, 2009 at 06:11 AM.
-
Mar 14th, 2009, 06:09 AM
#5
Re: [2005] MenuStrip Question
Hey,
Looks like you could be onto something there Nick, a quick google revealed this:
http://msdn.microsoft.com/en-us/library/ms404319.aspx
Good to know!!
Gary
-
Mar 14th, 2009, 05:08 PM
#6
Thread Starter
Hyperactive Member
Re: [2005] MenuStrip Question
thanks all.
found this thread very helpful.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 18th, 2009, 03:57 AM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] MenuStrip Question
hi all,
i know this thread is resolved but i'm having a problem somewhat related to this one...
i am able to do this using the Menu Strip but how do i do this using the ToolStrip.. i tried doing the same logic as the MenuStrip but somehow it doesn't seem to work with the ToolStrip.
can someone help me with this?
thanks
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 18th, 2009, 04:16 AM
#8
Re: [RESOLVED] [2005] MenuStrip Question
-
Mar 18th, 2009, 07:33 AM
#9
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] MenuStrip Question
hi,
thanks for the info...
i did follow both links but it only goes until the merging of menustrip and menustrip items but it doesn't go as far to merging toolstrip and toolstripbuttons.
i'm still looking for some other ways as of now... i'd appreciate any help.
thanks.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 18th, 2009, 07:57 AM
#10
Re: [RESOLVED] [2005] MenuStrip Question
Hey,
Ok, just done some more digging around, and I have come up with the following:
http://jdixon.dotnetdevelopersjourna...pplication.htm
Hopefully this will answer your question.
Gary
-
Mar 18th, 2009, 08:08 AM
#11
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] MenuStrip Question
hi,
thanks... this works... it's a little sad though that the automerging is not applicable in toolstrip unlike menustrip.
i did find a thread in the microsoft forums wherein it was said that only menustrip can do automerge... i hope they make this applicable in toolstrip as well in the future.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 18th, 2009, 08:11 AM
#12
Re: [RESOLVED] [2005] MenuStrip Question
Yeah, I am finding some references suggesting that it does work automatically, but everything I have seen so far (including testing) suggests that it doesn't, which is a bit of a shame.
At least you have it working though, that's the main thing.
Gary
-
Apr 11th, 2009, 05:12 AM
#13
Re: [RESOLVED] [2005] MenuStrip Question
Hey,
I know this is an older thread, but I have just been doing some reading, and I came across this:
http://msdn.microsoft.com/en-us/libr...r_members.aspx
Specifically the Merge Method:
http://msdn.microsoft.com/en-us/library/5523fet0.aspx
Hope that helps!!
Gary
-
Apr 11th, 2009, 08:15 AM
#14
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] MenuStrip Question
thanks... i'll check it out.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|