Question

I am disabling the parent menu option in a Windows forms menustrip. When you hover over it, the submenu still opens. Is there a way to disable the submenu opening or do I have to disable all the submenu items?

Was it helpful?

Solution 3

I ended up looping through the DropDownItems and disabling them after I disable the main item.

for (int i = 0; i < this._menuOpen.DropDownItems.Count; i++)
{
    this.menuOpen.DropDownItems[i].Enabled = false;
}

OTHER TIPS

Having the menu drop down show on mouse hover does not seem to be the default behavior of a ToolStripMenuItem and I could not find a property to enable this.

I did find this post by someone who wanted this behavior, and you should check to see if there is a MouseHover event handler for the ToolStripMenuItem and check the Enabled property there:

private void toolStripMenuItem1_MouseHover(object sender, EventArgs e)
{
    if (toolStripMenuItem1.Enabled)
        toolStripMenuItem1.DropDown.Show(menuStrip1, new Point(0, 0));
}

HTH

Just set the Enableproperty on the parent menu to False. In .net 2.0 and 3.5 the submenu will not show.

Also please try to be a little more specific.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top