views:

22

answers:

1

I started noticing strange behavior when navigating the main toolbar of my Winforms application, and I don't know how to fix it. When I initially open the dropdown of the File menu, it looks like this:

normal

I begin to scroll down each item with the arrow keys, and everything is fine until I reach "Exit". As soon as I hit the down arrow key from "Log Off", or if I hit the up arrow key from "Open", the menu rearranges itself to look like this:

alt text

I'm puzzled by this behavior. The menu still works, and from this point, if I start scrolling up, I can get the arrangement back to normal:

alt text

A few observations:

  • The menu still works.
  • This doesn't happen when using the mouse.
  • I have some code that toggles the Visible property of some of the menu items. I was able to modify what the arrangement was by playing around with this, but it was still messed up.

Can anyone help me understand what is going on, and how to fix it?

+2  A: 

I found the source of this problem. It is a known bug that Microsoft apparently doesn't intend to fix. The problem happens when you attempt to toggle visibility/availability of menu items during runtime. Microsoft reminds us that "this issue is purely visual, there's no functionality loss."

Their suggested workaround is to add/remove the menuitems rather than show/hiding them.

Another workaround is suggested on the forums: deriving from ToolStripDropDownMenu, turning off AutoSize, handling it on your own, and adding 1 extra pixel of height.

I found a blog post that addressed this issue, but the author never got around to posting his solution. He makes a useful point concerning Visible vs Available, however.

bentsai