hey guys,

I have this simple set a codes that opens a form as a child in MDI container.

Private Sub BarButtonItem1_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick

        frmConfirmShipment.MdiParent = Me
        frmConfirmShipment.Show()

        ''Dim NewMDIChild As New frmConfirmShipment() With {.MdiParent = Me}
        ''For Each ChildForm As Form In Me.MdiChildren
        ''If ChildForm.Name = NewMDIChild.Name Then
        ''ChildForm.Focus()
        ''Exit Sub
        ''End If
        ''Next
        ''NewMDIChild.Show()
    End Sub

When i run this set of codes, system keep telling me that same form cannot be both mdichild and mdiparent, however, I never set my child form as a parent.
Someone please help~!

Recommended Answers

All 3 Replies

This is the exact error message

Form cannot be both an MDI child and MDI parent.
Parameter name: value

You set the form to be MDI parent in your code and you still expect it to open in itself.

You set the form to be MDI parent in your code and you still expect it to open in itself.

what do you mean? I've been trying to figure this our all day and am very frustrated so please bare with me.
I don't know that you mean by 'open in itself'

I am trying to open a form called frmConfirmShipment from frmMain which is the MDI parent for all of my other forms. I have about 14 other forms that opens in MDI container without any problem but this one would keep giving me error message.

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.