Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
1.18/5 (3 votes)
See more:

I have a c# user control. I have a button in this control, and I want that when the user clicks on the button, another user control will be opened.

How can I do that?

Updated 24-May-17 10:26am

What user control is that?
Is it a Windows Application or Web Application?
You can use Properties of Visible to hide or show the control.
protected void Button1_Click(object sender, EventArgs e)
    userControl1.Visible = !userControl1.Visible;
Share this answer
I don't understand what you mean with 'open user control', but you can show, hide, add and remove controls.

Show controls[^]
Hide controls[^]
Add controls[^]
Remove controls[^]
Share this answer
Please try the following code

Window win = new Window();
UserControl1 eDoc = new UserControl1();
win.Content = eDoc;
win.Title = "User Control1";

Hope be helpful,
Share this answer
In your button click event, create a control and add it in the collection

myOwnControl userControl1 = new myOwnControl ();

Share this answer
Member 14167697 2-Mar-19 16:44pm    
Can you give more information about this? Where do you get the Controls property and how to use it? Thank you in advance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900