ContextMenuStrip 添加二级菜单,为什么二级菜单不能Checked?一级菜单却可以
解决方案 »
- 如何配置ODBC数据源
- 用c#写个winform程序,程序用HttpWebRequest调用一网址,返回中页面html代码,但发现html代码中js代码没有执行
- 求教 请问C# 里 "file:" 是什么意思啊?感谢
- 数据集包含多表,如何赋值?谢谢!
- 重载datagridviewColumn后的问题,感觉应该是一个BUG,大家来看一下哈,(顶者有分)
- 更改winform窗体标题栏的图标
- 关于开发word插件打包做安装文件的问题
- [请教、散分]我想写一个程序,目的是运行后始终占用80%左右的CPU使用量,有谁知道怎么做么?
- 求救~~~~
- 以前的shape和line控件怎么不见了?
- List<MyClass1> 类型的数据如何转换为List<MyClass2>类型的数据
- 数据归一化
把下面的代码添加到InitializeComponent函数试试:
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 26);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem1.Text = "toolStripMenuItem1";
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Checked = true;
this.toolStripMenuItem2.CheckState = System.Windows.Forms.CheckState.Checked;
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem2.Text = "toolStripMenuItem2";
是因为我的一级菜单单击的时候相应的是MyMenu_itemChecked()事件
二级菜单为什么不能相应这个事件呢?
是因为我的一级菜单单击的时候相应的是MyMenu_itemClicked()事件
二级菜单为什么不能相应这个事件呢?
为啥呢?
例如:
this.toolStripMenuItem2.CheckedChanged += new System.EventHandler(this.toolStripMenuItem2_CheckedChanged);
上面的toolStripMenuItem2是二级菜单,toolStripMenuItem2_CheckedChanged函数相当于MyMenu_itemClicked;
查找你的代码中是否也有对应的代码。