开发者

how to click on usercontrol to open anoter usercontrol?

开发者 https://www.devze.com 2023-02-09 07:41 出处:网络
im using visual c# 2008,i have tried to openusercontrol2 fromusercontrol1. using event handling yet still unable 开发者_开发百科to load the usercontrol1, but able to close the usercontrol1.

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

精彩评论

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