如何检测上下文菜单消失?

发布于 2024-10-12 00:11:04 字数 324 浏览 3 评论 0原文

我需要制作一个带有弹出菜单和按钮的控件,使其显示并在弹出菜单可见期间更改(按下)外观。

目前我正在使用复选框,外观属性设置为按钮和上下文菜单。然而,检测菜单因任何原因消失的时刻,然后单击其中一个项目(生成可以处理的 Click 事件) - 例如,当单击表单时 - 没有成功,因为“折叠”事件没有成功t 发生。结果,“向下箭头按钮”并没有按预期改变其外观。

如何检测ContextMenu的消失? “崩溃”事件发生的条件是什么?

PS 在相关说明中,我之前尝试将列表框设置为顶级窗口来实现相同的功能;单击表单时,它会改变外观,但不会发生焦点丢失。任何有关检测其发生时刻的帮助将不胜感激。

I need to make a control with popping out menu and button that causes it to be displayed and has changed (pressed) appearance during the time popped out menu is visible.

Currently i am using check box with Appearance property set to button and context menu. However detecting a moment when menu disappears from any reason other then click on one of its items (which generates Click event that can be handled) - for example, when the form is clicked - wasn't successful, as "Collapse" event didn't occur. As a result, "down-arrow button" didn't change its appearance back as intended.

How can disappearance of ContextMenu be detected? What are conditions for "Collapse" event to occur?

P.S. On related note, i was trying to implement the same thing with listbox set as top level window before; when form was clicked, it changed appearance but the loss of focus didn't occur. Any help with detecting the moment when it occurs would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

新一帅帅 2024-10-19 00:11:04

如果您使用 ContextMenuStrip 您可以处理Closed 事件在菜单关闭时引发。

“如何检测 ContextMenu 的消失?发生“Collapse”事件的条件是什么?”

Collapsed 事件仅在 ContextMenu 设置为 ContextMenu 时引发调用 Show 之前的控件

If you use the ContextMenuStrip you can handle the Closed event which is raised when the menu is closed.

"How can disappearance of ContextMenu be detected? What are conditions for "Collapse" event to occur?"

The Collapsed event is only raised of the ContextMenu is set as the ContextMenu of a control before you call Show

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文