C#中的RadioButton和CheckBox的使用
来源:百度知道 编辑:UC知道 时间:2024/04/19 14:55:24
{
if(this.checkBox1.Checked)
{
MessageBox.Show("一选中 二将选");
this.checkBox2.CheckState = CheckState.Checked;
return;
}
if(this.checkBox2.Checked)
//else
{
MessageBox.Show("二选中 三将选");
this.checkBox3.CheckState = CheckState.Checked;
return;
}
if(this.checkBox3.Checked)
{
MessageBox.Show("三选中 四将选");
this.checkBox4.CheckState = CheckState.Checked;
return;
}
this.checkBox1.CheckState = CheckState.Checked;
}
private void button3_Click(object sender, System.EventArgs e)
{
if(this.radioButton1.Checked)
{
this.radioButton2.Select();
return;
}
if(this.radioButton2.Checked)
{
this.radioButton3.Select();
return;
}
你用的方法不合理,如果第1个和第2个同时被选中的话代码只会执行
if(this.checkBox1.Checked)
{
MessageBox.Show("一选中 二将选");
this.checkBox2.CheckState = CheckState.Checked;
return;
}
这就是为什么不管如何点击,第三个不会被选中的原因。
改成:
private void button2_Click(object sender, System.EventArgs e)
{
if(this.checkBox1.Checked && (!this.checkBox2.Checked))
{
MessageBox.Show("一选中 二将选");
this.checkBox2.CheckState = CheckState.Checked;
return;
}
if(this.checkBox2.Checked(!this.checkBox3.Checked))
//else
{
MessageBox.Show("二选中 三将选");
this.checkBox3.CheckState = CheckState.Checked;
return;
}
if(this.checkBox3.Checked)
{
MessageBox.Show("三选中 四将选");
this.checkBox4.CheckState = CheckState.Checked;
return;
}
this.checkBox1.CheckState = CheckState.Checked;
}
路过。
顺便请大家帮忙看一下我的问题(200分悬赏),解决问题的另加100分。
C#中的RadioButton和CheckBox的使用
C# RadioButton
c# windows 中 radiobutton 的绑定
c#中点击radiobutton后再保存入数据库,请问代码怎样实现?
c++ Radiobutton
什么是C#中的映射
c#中的数组问题?
c#中的&nbsp是什么意思?
C#中的{0}是什么意思?
c#问题中的textbox