MDI Form VB.Net in Visual Studio 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StrykerNet
    New Member
    • Aug 2008
    • 13

    MDI Form VB.Net in Visual Studio 2005

    I'm trying to create a new app in MDI but I cant seem to get the children correct. The farthest I got was setting the IsMDIContainer to True. How would I proceed? Also, I have my own menu bar on the left side of the window with buttons that should lead to the children. My menu bar keeps the focus when I try to open other windows. Please advise.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You set the parent's IsMDIContainer to true, not the child's.

    Set the child's MDIParent = to an instance of the mdi parent form.

    What I usually do is modify the constructor to take a parameter of the type that your mdi parent is. For example, if you named the parent's class myMdiParent, then the child's constructor should look like this:
    Code:
    'in myMdiChild
    Public Sub New(myMdiParent parent)
    {
      Me.MDIParent = parent
    }
    And you can instantiate this form like this
    Code:
    'somewhere in myMdiParent
    Dim child As New myMdiChild(me)
    child.Show()
    Just replace myMdiChild and myMdiParent with the proper class names.

    I can't remember off the top of my head how to merge menu bars, but I'll dig up one of my old apps and find it tomorrow.

    Hope that helps
    I haven't tested this code (I usually work in C#)

    Comment

    Working...