Reputation: 391
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
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
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