Create an overloaded constructor for UserControl1, passing the Panel
control as your parameter.
In this way, you can assign the Panel to the Parent property of
UserControl2 after instantiating UserControl2 from
a button click event. The button as I understand it, is located in the
UserControl1 right?

Here is a sample which might help you:


http://benjnunez.pastebin.com/nV7fdAGn


To see your output, I recommend you place some labels in UserControl1
and UserControl2
or better yet, temporarily change the color of your forms (e.g. blue
for UserControl1 and green for UserControl2).



Regards,



Benj






On Nov 21, 10:25 am, Carlos Caetano <[email protected]> wrote:
> Hi,
>
> I have a Panel named *panel1 *and two User Controls named *uc1 *and *uc2*.
>
> I add UserControl in Panel with de following command:
>
> uc1 myuc1 = new uc1();
> panel1.Controls.Add(myuc1);
>
> How can I remove the User Control *uc1 *from panel and add *uc2 *with event
> from button inside *uc1*.
>
> Tks, And sorry for my English*
> *
> --
> Carlos Caetano

Reply via email to