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

Nov 17, 2012 By Anil Gaikwad

Consider a scenarion when you are having A MDIContainer form frmParent which is MDIParent and two MDIChildren forms frmChild1 and frmChild2. Now you can open frmChild1 or frmChild2 from frmParent directly so that those forms will bw contained in frmParent only.

Now what if suppose you have opened frmChild1 form in frmParent using below code

frmChild1 fr = new frmChild1() fr.MDIParent = me fr.show()

now on frmChild1 you have a button which opens the form frmChild2 which you want to open in frmParent only

frmChild2 fr2 = new frmChild2() fr2.MDIParent = me fr2.show()

when you write above code it will give you error saying that "Form cannot be both an MDI child and MDI parent. Parameter name: value" because in above code you are trying to set frmChild1 which is MDIChildren as MDIParent

Solution: frmChild2 fr2 = new frmChild2() fr2.MDIParent = frmMain fr2.show()