button not work after usercontrol change to another usercontrol

Viewed 32

I have button in usercontrol1 which hide/show panel in the main form. when i change usercontrol1 to usercontrol2 and back to usercontrol1 again then click button on it, it does not working anymore panel in main form wont show/hide anymore.

here that code.

usercontrol1:

    public event EventHandler ButtonClick;

    private void button1_Click(object sender, EventArgs e)
    {
        //bubble the event up to the parent
        if (this.ButtonClick != null)
            this.ButtonClick(this, e);

    }

form: usercontrol.ButtonClick += new EventHandler(UserControl_ButtonClick);

    private void UserControl_ButtonClick(object sender, EventArgs e)
    {
        bunifuGradientPanel1.Visible = !bunifuGradientPanel1.Visible;

    }
0 Answers
Related