how to click on usercontrol to open anoter usercontrol?
im using visual c# 2008,i have tried to open usercontrol2 from usercontrol1. using event handling yet still unable 开发者_开发百科to load the usercontrol1, but able to close the usercontrol1.
please help me..
Give this a Try
void UserControl1_Click(object sender, EventArgs e)
{
UserControl2 u2 = new UserControl2();
this.Parent.Controls.Add(u2); // if you want to add to parent
//this.Controls.Add(u2); // if you want to add to the first UserControl
u2.BringToFront();
this.Visible = false;
u2.Visible = true;
}
I think your problem is that you did not assign usercontrol2 to a parents control collection.
精彩评论