1

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?

3 Answers 3

1

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

0

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.

2
  • This is not true. It does show. The first time you click on it, it does not, but if you click on it a second time it does.
    – SchwartzE
    Nov 1, 2010 at 13:35
  • I have just checked again, on a second computer and my result is valid. Maybe you should try and post more details, a screenshot maybe. Nov 1, 2010 at 13:43
0

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.