Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu Items on Winforms... disabled going down, enabled going up...

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,305
FR
Is this normal?

I have a form with a menu bar on it, one of the options, which has a sub-menu, is disabled.

If I move the mouse cursor down the list the result is perfect, you can hover over the item
in question and the sub-menu does not appear - great.

If I then move one (enabled) item down, the sub-menu for that item appears - correctly...

But if I now move back up, and hover over the disabled item, the sub-menu for it appears and
I can click on the sub-menu items that shouldn't be available.

In fact, this isn't just an up/down thing, if I hover over ANY menu item with sub-items, I can then access
the disabled ones sub-menu items as well.

This can't be right can it?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Which version of .NET are you targeting and how did you disable the menu?

I did a little test (4.5 framework) and then I disabled by just going into the code and adding the Enabled = false. Working perfectly.

Code:
[COLOR=#008000]// [/color]
            [COLOR=#008000]// subMenuTwoToolStripMenuItem[/color]
            [COLOR=#008000]// [/color]
            [COLOR=#0000FF]this[/color].subMenuTwoToolStripMenuItem.DropDownItems.AddRange([COLOR=#0000FF]new[/color] System.Windows.Forms.[COLOR=#2B91AF]ToolStripItem[/color][] {
            [COLOR=#0000FF]this[/color].subMenu2x1ToolStripMenuItem,
            [COLOR=#0000FF]this[/color].subMenu2x2ToolStripMenuItem});
            [highlight #FCE94F][COLOR=#0000FF]this[/color].subMenuTwoToolStripMenuItem.Enabled = [COLOR=#0000FF]false[/color];[/highlight]
            [COLOR=#0000FF]this[/color].subMenuTwoToolStripMenuItem.Name = [COLOR=#A31515]"subMenuTwoToolStripMenuItem"[/color];
            [COLOR=#0000FF]this[/color].subMenuTwoToolStripMenuItem.Size = [COLOR=#0000FF]new[/color] System.Drawing.[COLOR=#2B91AF]Size[/color](161, 22);
            [COLOR=#0000FF]this[/color].subMenuTwoToolStripMenuItem.Text = [COLOR=#A31515]"Sub Menu Two"[/color];
 
Hi

It's .NET framework 4.0.30319, visual studio 2010

I ended up just making it invisible, but it's really annoying, because sometimes you want users
to see what would be available if they logged in or whatever

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Hmmm. Are you launching it initially enabled and then disabling it in the code, or the other way around?
 
I am disabling it in code, from an enabled state.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
How strange; even changing it to work that way I can't seem to reproduce the issue you're having.
 
It's not behaviour I would expect.

I'm not disabling the submenu items individually, just the parent, and it only 'reenables' the
submenu items if I hover over another (any other) enabled menu items with sub items.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top