C#第二个按钮单击重置已更改的项目

时间:2013-11-04 21:43:28

标签: c# events button reset

首先,我希望标签,链接和其他按钮在首次单击question_group2时消失并移动。但在此之后,我想再次点击同一个按钮后重置项目。这是我的代码。它首先做我想要的,但我无法弄清楚如何在第二次点击时重置。我还必须继续运行,所以第三次点击会消失所有内容,第四次会再次重置所有内容。请帮忙。谢谢

    private bool button2Clicked = false;        

    private void question_group2_Click(object sender, EventArgs e)
    {
        button2Clicked = true;
        if (button2Clicked == true)
        {
            this.question_group3_button.Location = new System.Drawing.Point(169, 284);
            this.question1_label.Visible = false;
            this.question2_label.Visible = false;
            this.question3_label.Visible = false;
            this.question4_label.Visible = false;

            this.question1_link.Visible = false;
            this.question2_link.Visible = false;
            this.question3_link.Visible = false;
            this.question4_link.Visible = false;

            this.add_question_link.Visible = false;
        }

1 个答案:

答案 0 :(得分:3)

this.question1_label.Visible =!this.question1_label.Visible
每次单击都会将可见性设置为相反的值