我想取消选中其他表单关闭时的 ContextMenuStrip 项目。这是我的代码:
表格1:
public bool ischecked
{
get { return openForm1ToolStripMenuItem.Checked; }
set { openForm1ToolStripMenuItem.Checked = value; }
}
bool isForm2Open = false;
bool isForm3Open = false;
private void openForm1ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!isForm2Open)
{
Form2 frm2 = new Form2();
frm2.Show();
isForm2Open = true;
openForm1ToolStripMenuItem.Checked = true;
}
else
{
openForm1ToolStripMenuItem.Checked = false;
isForm2Open = false;
}
}
表格2:
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
// Code for Unckeck openForm1ToolStripMenuItem
}
为什么 ischecked 不能以其他形式访问?