使ToolStripMenuItem.Selected = true的最简单方法

时间:2012-10-02 14:48:09

标签: c# winforms

我有一个名为ToolStripMenuItem的{​​{1}}。现在,当用户点击它时,我希望它为mailResultsToolStripMenuItem,当用户再次点击它时,我希望.Selected = true.Selected = false我试过了:

mailResultsToolStripMenuItem.Selected = true;

但它显示错误,该属性只读

1 个答案:

答案 0 :(得分:1)

你在寻找ToolStripMenuItem.Checked吗?

// true if the ToolStripMenuItem is checked or is in an indeterminate state;
// otherwise, false. The default is false.
mailResultsToolStripMenuItem.Checked = true;
// Also interesting: mailResultsToolStripMenuItem.CheckState
//                   mailResultsToolStripMenuItem.CheckOnClick