Replace splitcontainer panel usercontrol

Hi,

I'm using the splitcontainer control, assigning a usercontrol to panel2.

How do I change the currently assigned usercontrol to panel2 from within the current usercontrol which is currently assigned to panel2.

ie. a button is clicked on the current usercontrol and now must be replaced with a new usercontrol.

Cheers

John



Answer this question

Replace splitcontainer panel usercontrol

  • robinjam

    Btw. Why you don't put both controls to form at design mode, change other visible to false and then on button click change those visible values.

    Markku


  • JLLO

    Hi

    Inside usercontrol use this.Parent property to reference to the container (Panel2) and if you need reference to the spitcontainer use this.Parent.Parent

    Markku


  • ahmedilyas

    >You can do it in the same way as normal panel.

    >Insted of 'Panel2' you must use '<splitContainerName>.Panel2' where <splitContainerName> is your component name >example 'splitContainer1'.

    How do i get access to the splitcontainer from the usercontrol which was first assigned to the panel2

    Usercontrol is assigned for the first time as

    private void Form1_Load(object sender, EventArgs e)

    {

    us = new UserControl1();

    us.Dock = DockStyle.Fill;

    this.splitContainer1.Panel2.Controls.Add(us);

    }

    But inside the UserControl1 is there a reference to the splitcontainer form object

    Cheers

    John


  • su45937

    Will that use more resources as the 20 usercontrols I have would all need to be allocated and have database connections each

    Thanks

    John


  • toughtalk

    Using this.Parent.Parent does not work is says "Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement"
  • NozFx

    Hi

    You can do it in the same way as normal panel.

    Insted of 'Panel2' you must use '<splitContainerName>.Panel2' where <splitContainerName> is your component name example 'splitContainer1'.

    Yours Markku


  • Replace splitcontainer panel usercontrol