有一系列需要勾选的内容,勾选完内容后,会根据勾选内容自动生成一个对应的表单。
不同的勾选内容,生成的表单内容是不一样的。
checkbox勾选方法:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
this.textBox1.Visible =this.checkBox1.Checked;
this.label1.Visible =this.checkBox1.Checked;
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
this.textBox2.Visible = this.checkBox2.Checked;
this.label2.Visible = this.checkBox2.Checked;
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
this.textBox3.Visible = this.checkBox3.Checked;
this.label3.Visible = this.checkBox3.Checked;
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
this.textBox4.Visible = this.checkBox4.Checked;
this.label4.Visible = this.checkBox4.Checked;
}
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
this.textBox5.Visible = this.checkBox5.Checked;
this.label5.Visible = this.checkBox5.Checked;
}
private void checkBox6_CheckedChanged(object sender, EventArgs e)
{
this.textBox6.Visible = this.checkBox6.Checked;
this.label6.Visible = this.checkBox6.Checked;
}
InitializeComponent里面隐藏所有textBox和label:
private void hideAll()
{
this.label1.Visible= false;
this.label2.Visible= false;
this.label3.Visible= false;
this.label4.Visible= false;
this.label5.Visible= false;
this.label6.Visible= false;
this.textBox1.Visible= false;
this.textBox2.Visible= false;
this.textBox3.Visible= false;
this.textBox4.Visible= false;
this.textBox5.Visible= false;
this.textBox6.Visible= false;
}
private void InitializeComponent()
{
hideAll();
}