user1439691
user1439691

Reputation: 391

open c# user control from another user control

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?

Thanks

Upvotes: 1

Views: 3799

Answers (2)

Adil
Adil

Reputation: 148180

You have to create the control you want to add and add it.

YourCustomControl uc = null;

private void button1_Click(object sender, EventArgs e)
{
     uc = new YourCustomControl();
     this.Controls.Add(uc); // this represent the user control in which you want to add
                            // You can add it in some container like Panel or GroupBox
}

Upvotes: 1

Paul Alan Taylor
Paul Alan Taylor

Reputation: 10680

Take a look at RaiseBubbleEvent. This pushes an event up to its parent.

http://msdn.microsoft.com/en-us/library/aa719644(v=vs.71).aspx

Upvotes: 0

Related Questions