延迟打开菜单条中的子菜单
我们的环境:Visual Studio 2010、c#、.net 4 客户端配置文件。
我们有一个 Winforms 应用程序,其主窗体中包含一个菜单条。菜单条的项目包含图像 (64x64) 和文本。主窗体还有一个 TabControl,其中包含 5 个选项卡。在主窗体的 OnLoad() 方法中,我们隐藏 TabControl 标头,以便它们不可见,因此不可单击。相反,当用户单击菜单条中的某个项目时,我们会切换活动选项卡。
然而,我们的菜单有很多子菜单项,并且由于我们使用主菜单条来选择活动选项卡,因此我们希望子菜单项仅在用户单击菜单项一段时间后才出现,而不是立即出现。否则,每当用户更改他/她的活动视图(通过选择 tabPage)时,子菜单就会出现在屏幕上,因为他/她单击了包含子菜单的菜单条项目。
这可能吗?
Our environment: Visual Studio 2010, c#, .net 4 client profile.
We have a Winforms application that contains a menustrip in its main form. The items of the menustrip contain both an image (64x64) and text. The main form also has a TabControl which contains 5 tabs. In the OnLoad() method of the main form, we hide the TabControl headers so that they are not visible and therefore not clickable. Instead, when the user clicks on an item in the menustrip, we switch the active tab.
However, our menus have many sub-menu items, and since we use the main menustrip to select the active tab, we would like the sub-menu items to appear only after the user clicks the menu item for a period of time, not instantaneously. Otherwise, whenever the user changes his/her active view (by selecting a tabPage), the sub-menus appear on the screen since he/she clicked a menustrip item that contains sub menus.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全理解其基本原理,但是您可以使用 MouseDown 处理程序和 sleep 函数来延迟子菜单的显示,如下所示:
===================== =
(编辑:添加了第二个解决方案)
您可以使用计时器控件和 ShowDropDown/HideDropDown 来完成此操作:
I don't completely understand the rationale, but you can delay the display of a submenu using the MouseDown handler and sleep function, like this:
======================
(Edit: Added second solution)
You can do this with a timer control and ShowDropDown/HideDropDown: