思路是这样的,在一个form上有一个checkbox1,一个textbox1form在load的时候,把textbox的enable设置成false
然后
必须checkbox1打钩了,textbox1才能变亮能输入我是这样写的:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.CheckState==checked)
{
this.textBox1.Enabled = true;
}含有if的这行报错 : 语法错误,应输入"("不知道是哪里写错了另外这种思路对么?做这个事情的时候用CheckState来判断checkbox是否打钩了多谢各位
然后
必须checkbox1打钩了,textbox1才能变亮能输入我是这样写的:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.CheckState==checked)
{
this.textBox1.Enabled = true;
}含有if的这行报错 : 语法错误,应输入"("不知道是哪里写错了另外这种思路对么?做这个事情的时候用CheckState来判断checkbox是否打钩了多谢各位
{
this.textBox1.Enabled = true;
}
else
{
this.textBox1.Enabled = false;
}
this.checkBox1.CheckState 是枚举类型的:CheckState.Checked、CheckState.Indeterminate和CheckState.Unchecked。
你的需求只要用
this.textBox1.Enabled = checkBox1.Checked;
就行了。