不要关闭的ContextMenuStrip上选择某些项目 [英] Do not close ContextMenuStrip on selection of certain items

查看:308
本文介绍了不要关闭的ContextMenuStrip上选择某些项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能留下的ContextMenuStrip打开某些项目的选择/检查后?

Is it possible to leave a ContextMenuStrip open after a selection/check of certain items?

我打算用一个简单的ContextMenuStrip设置一个过滤器(这样我可以使用相同的过滤器无论是在菜单或右键单击选项)。

I plan on using a simple ContextMenuStrip to set a filter (this way i could use the same filter either in a menu or as a right-click option).

的菜单中列出的许多项目,我想的用户能够进行选择的使用基本检查功能的项目。一旦选择完成后,用户可以单击激活过滤选项,也可以点击菜单要么之外激活或取消该过滤器。

The menu lists a number of items, and i would like the user to be able to make a selection of the items using the basic Check functionality. Once the selection is done the user can click an Activate filter option or can click outside the menu to either activate or cancel the filter.

在选择/单击事件菜单正常关闭。 是否有可能保持在菜单上单击事件开?

On a selection/click event the menu normally closes. Is it possible to keep the menu open on a click event?

推荐答案

要prevent从收盘时的项被点击,请执行下列操作的文本菜单。

To prevent the contextmenu from closing when an item is clicked, do the following.

在ContextMenuItems的鼠标按下事件中设置标志设置为false,然后将其设置回真正的在文本菜单的闭幕活动。

On mousedown event of ContextMenuItems set flag to false then set it back to true at the closing event of the contextmenu.

例如:

Private blnClose As Boolean = True

Private Sub MoveUpToolStripMenuItem_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MoveUpToolStripMenuItem.MouseDown

     blnClose = False

End Sub

Private Sub ContextMenuStrip1_Closing(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripDropDownClosingEventArgs) Handles ContextMenuStrip1.Closing

     e.Cancel = Not blnClose
     blnClose = True

End Sub

这篇关于不要关闭的ContextMenuStrip上选择某些项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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