基本上,我有一个递送复选框列表,一个是递送到这个地址,另一个是递送到一个单独的地址,我基本上想让它一旦被选中,另一个就不能被检出(可能是通过灰显或沿着这些线的东西)
请注意,这两个框使用相同的控件。
发布于 2012-06-14 20:26:57
使用如下方法监听第一个CheckBox的CheckedChanged事件:
private void checkBox1_checkedChanged(object sender, EventArgs e)
{
this.checkBox2.Enabled = !this.checkBox1.Checked;
// If you want it to be unchecked as well as grayed out,
// then have this code as well:
if (!this.checkBox2.Enabled)
{
this.checkBox2.Checked = false;
}
}但是,如果在逻辑上符合您的需要,您应该考虑使用RadioButtons而不是CheckBoxes。
发布于 2012-06-14 20:26:40
使用以下代码,
checkboxToBeGreyed.Enabled = false;您已经在其他checkbox的选中事件中编写了此代码。希望这能有所帮助。
https://stackoverflow.com/questions/11033017
复制相似问题