Results 1 to 14 of 14

Thread: [RESOLVED] [2005] MenuStrip Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Resolved [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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  4. #4
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    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:
    1. Dim f As New FormMdiChild
    2.         f.MdiParent = Me
    3.         f.Show()

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    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

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2005] MenuStrip Question

    Hey,

    I think this might help you out:

    http://msdn.microsoft.com/en-us/libr...40(VS.80).aspx

    This links through to a complete walkthrough:

    http://msdn.microsoft.com/en-us/libr...76(VS.80).aspx

    Gary

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    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

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    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

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    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
  •  



Click Here to Expand Forum to Full Width