两个checkbox的控件控制操作只能选其一
CheckedChanged,与CheckStateChanged事件,都是在代码中更改属性都会触发的,因为都是
.CheckedChanged += new System.EventHandler();
.CheckStateChanged += new System.EventHandler();
private void CodeToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (CodeToolStripMenuItem.CheckState == CheckState.Checked)
{
NameToolStripMenuItem.Checked = false;
CodeToolStripMenuItem.Enabled = false;
NameToolStripMenuItem.Enabled = true;
//执行相关数据操作
}
}
private void NameToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (NameToolStripMenuItem.CheckState == CheckState.Checked)
{
CodeToolStripMenuItem.Checked = false;
NameToolStripMenuItem.Enabled = false;
CodeToolStripMenuItem.Enabled = true;
//执行相关数据操作
}
}