自定义的ToolStripMenuItem 如何实现checked状态的改变.
请教大家:
自定义的ToolStripMenuItem 如何在 XXXXXXXXXXXXXXXXXXXXXXXXXXX位置实现checked状态的改变.
ToolStripMenuItem DevMenu = new ToolStripMenuItem();
DevMenu = new ToolStripMenuItem();
for (i = 0; i < al.Count; i++)
{
DevIncludeM[i] = new ToolStripMenuItem();
DevIncludeM[i].Name = al[i].ToString();
DevIncludeM[i].Text = al[i].ToString();
DevIncludeM[i].Click += new EventHandler(DevIncludeM_Click);
}
private void DevIncludeM_Click(object sender, EventArgs e)
{
switch (((System.Windows.Forms.ToolStripDropDownItem)sender).Text)
{
case "快捷工具条" :
XXXXXXXXXXXXXXXXXXXXXXXXXXX
break;
}
}
------解决方案-------------------- switch (((System.Windows.Forms.ToolStripDropDownItem)sender).Text)
{
case "快捷工具条" :
快捷工具条.Checked=!快捷工具条.Checked;
break;
}
------解决方案--------------------将CheckOnClick设为true,然后在OnClick里面修改Checked就好了。