开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜