如何禁用上下文菜单中包含分隔符项的所有菜单项?
我的做法:
For Each item As ToolStripMenuItem In ContextMenuStrip1.Items
item.Enabled = False
Next
如果我在菜单中没有分隔符但使用分隔符我得到错误:
无法将“System.Windows.Forms.ToolStripSeparator”类型的对象转换为“System.Windows.Forms.ToolStripMenuItem”类型。
如何禁用菜单中包含分隔项的所有项目?