locked
problem with user control RRS feed

  • Question

  • hey , i am new to microsoft visual c# and i'm facing this small problem


    i have created a form and two user controls us1 & us2 ... i hav divided the form in two panels pn1 n pn2 using split container .........

    on load user control us1 is loaded in splitcontainer1.panel1 now wen i click on the button in usercontrol us1 , i want the other usercontrol us2 to b open up in splitcontainer.panel2...........



    please help its urgent

    thanx in advance

     

    Thursday, April 17, 2008 8:21 AM

Answers

  • When you add a new control to Panel1, attach a Click event handler to it. When the event is raised, do the following:

     

    Code Snippet

    private void myControl_Click(object sender, EventArgs e)

    {

    splitContainer1.Panel2.Controls.Clear();

    Control ctr = new Control();

    ctr.Dock = DockStyle.Fill;

    splitContainer1.Panel2.Controls.Add(ctr);

    }

     

     

    Thursday, April 17, 2008 7:48 PM