How to hide form panel using button in the usercontrol

Viewed 29

How can i hide panel using button. The panel is inside Form1 and i want to add button Hide/Show panel in the UserControl. How can i call it?

so it look like this: Form1(contain panel) ---> add button Hide/Show in UserControl

I saw a post what i am looking for but it wont work. anyone why is not working . here what i do.

Form1:

    private void userControl2_Button1Click(object sender, EventArgs e)
    {
        flag *= -1;
        if (flag == 1)
            bunifuGradientPanel1.Hide();
        else
            bunifuGradientPanel1.Show();

    }

UserControl:

 button1.Click += button1_Click;


    public event EventHandler Button1Click;

    protected virtual void OnButton1Click(EventArgs e)
    {
        //Button1Click.Invoke(this, e);
        var handler = Button1Click;
        if (handler != null)
            handler(this, e);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        OnButton1Click(EventArgs.Empty);

    }
0 Answers
Related