Greetings Everyone,

I have several forms in my project and I have set the IsMdiContainer property to True on my main form.

This project also is not using a menu system. Instead I'm using a 3rd party ribbon control with buttons that call the other forms in the project.

Can you tell me how to set the other existing forms in the project as MDI child forms?

Thanks.

Truly,
Emad

Dani AI

Generated

Quick practical summary for : with your main form configured as the MDI container, child forms must be created by the parent (or by code that holds a reference to the parent), assigned that parent, then shown modeless. The ribbon control only supplies the button clicks — it does not change how MDI works. Avoid using ShowDialog() for forms you want as MDI children.

A small, reusable pattern that avoids opening duplicate children:

' Open-or-activate a single instance of a child form type
Public Sub OpenChild(Of T As {Form, New})(main As Form)
    For Each f As Form In main.MdiChildren
        If TypeOf f Is T Then
            f.Activate()
            Return
        End If
    Next

    Dim child As New T()
    child.MdiParent = main
    child.WindowState = FormWindowState.Normal  ' or Maximized
    child.Show()
End Sub

Troubleshooting notes and tips:

  • If a child appears as a separate top-level window, the code likely used the wrong parent instance. If the ribbon code lives outside the main form, locate the main form (pass it in, use FindForm() from the control, or search Application.OpenForms) and pass that reference to the helper above.
  • Always set MdiParent before calling Show(). Modal (ShowDialog) forms will not behave as MDI children.
  • Use main.LayoutMdi(...) or iterate main.MdiChildren to arrange or communicate between children.
  • Only the main form should have IsMdiContainer = True; child forms should remain standard forms.

In short: pointed you in the right direction and ’s parent-form advice is correct — combine that approach with the helper pattern and the parent-reference tips above to get robust MDI behavior from your ribbon buttons.

Recommended Answers

All 3 Replies

Dim frm as New From1
frm.MdiParent=Me  'Reference of MDI Parent
frm.Show()

Hi,

In addition Adatapost has written:

You need to create a parentform, to do so you can use Form1 and rename it parentform.vb. Then you need to set the property IsMDIContainer = true. When you add a new form to your application you'll see that it will create a Form1 again. Then use Adatapost's code.

commented: Helpful! +9

Hi Everyone,

Thanks for the replies.

They are very helpful.

Truly,
Emad

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.