在残疾人士的WinForms菜单项仍显示子项 [英] Disabled menu items in Winforms still show subitems

查看:138
本文介绍了在残疾人士的WinForms菜单项仍显示子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建了两个项目的菜单(说项目1和项目2,然后创建每一个在两个分项目(1A,1B,2A和2B),然后禁用项目1,我期望1A和1B就不会显示。

If I create a menu with two items (say "Item1" and "Item2" and then create two subitems under each one (1A, 1B, 2A and 2B), and then disable Item1, I'd expect that 1A and 1B wouldn't show.

和,事实上,如果我移动到项目1他们并不知道,除非我然后转移到项目2,等待2A和2B展示,然后回迁项目1。在这一点1A和1B都弹出,充分活跃。

And, indeed, if I move onto Item1 they don't. Unless I then move on to Item2, wait for 2A and 2B to show, and then move back to Item1. At which point 1A and 1B both pop up, fully active.

这是一个已知的bug?有什么事情我可以解决?有什么建议?

Is this a known bug? Is it something I can work around? Any suggestions?

的用户希望能够看到当前禁用的东西,或者我只是让看不见的东西。不幸的是,这是不是一种选择我们可以方便地使用。

The users want to be able to see the things that are currently disabled, or I'd just make things invisible. Sadly, this isn't an option we can easily use.

推荐答案

我可以证实,这与MenuStrip中发生了框架2.0,3.5和4.0。唯一合理解决方法,我所能做的就是在可见属性设置为,因此该项目不会出现在所有。不理想,但比其子项访问的更好。

I can confirm that this occurs with the MenuStrip for Framework 2.0, 3.5 and 4.0. The only reasonable workaround that I have is to set the Visible property to false, so the item does not appear at all. Not Ideal, but better than having the sub-items accessible.

当然,你也可以创建将递归禁用所有子项的功能,即使他们出现,他们这样至少被禁用,您将需要保持先前的状态,以确保您没有在以后重新启用,实际上是inteded被禁用子项等文档表示,这其实是发生了什么,但事实并非情况下,即使父项将被禁用子项目保持启用状态。

Of course you can also create a function that will recursively disable all child items, that way even if they appear, they are at least disabled, you will need to maintain the previous state to ensure that you do not later re-enable a child item that is actually inteded to be disabled etc. The documentation indicates that this is actually what happens, but that is not the case, sub-items remain enabled even when the parent item is disabled.

这篇关于在残疾人士的WinForms菜单项仍显示子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆