-2

I am using a SplitContainter in MDI parent Form.

My problem is I loaded a form in panel1 named First Form. In this First Form with a button I load SecondForm in panel2.

I am using this code:

        Form In_but = new SecondForm();
        In_but.MdiParent = this.ParentForm;
        In_but.TopLevel = false;
        this.splitContainer1.Panel2.Controls.Add(In_but);
        In_but.Show();

But it's not working. The error is: does not contain definition splitContainer1.

pb2q
  • 58,613
  • 19
  • 146
  • 147
user1158914
  • 1
  • 1
  • 2

3 Answers3

0

From looking at your code sample, I suspect your problem is when you refer to this.splitContainer, this is your 'First form' on panel 1, and your SplitContainer is on this.ParentForm.

I'd suggest changing that line to this.(ParentForm as <whatever class your parent form is>).splitContainer1.Panel2.Controls.Add(In_but);

Flynn1179
  • 11,925
  • 6
  • 38
  • 74
0

try this

frmChild frmChild = new frmChild();
        frmChild.TopLevel = false;
        frmChild.Parent = this.splitContainer3.Panel2;
        frmMasterlistAdministrationAdd.Show();
devkiat
  • 139
  • 2
  • 6
  • 16
-1
frmTest fs = new frmTest();  //frmTest is the form that you going to call 

fs.MdiParent = this; //the main form is a mdiform and have a splitcontainer with 
                     //two panels

this.splitContainer1.Panel2.Controls.Add(fs); //add the fs form to the panel2

fs.Show(); //show the form
athspk
  • 6,722
  • 7
  • 37
  • 51
omidud
  • 1
  • Why would changing the variable you're adding to a container somehow change the error `does not contain definition splitContainer1` – Conrad Frix Sep 28 '12 at 21:48