Search code examples
c#.netoopmdimdichild

mdi form-->> child form 1(button-->> child form2) c # child form from button of some other child form


i have mdi form "m1" in which OnLoad open child form "ch1" in child form i have one button "b1" which further open new form "ch2" but that form should be the child of "md1" ch2.MdiParent = this; is not working form me


Solution

  • Since Child Form 2 is being created by Child Form 1, it needs to reference the MdiParent of Child Form 1, not this (which is not an MDI form):

    ch2.MdiParent = this.MdiParent;