如何检测上下文菜单消失?
我需要制作一个带有弹出菜单和按钮的控件,使其显示并在弹出菜单可见期间更改(按下)外观。
目前我正在使用复选框,外观属性设置为按钮和上下文菜单。然而,检测菜单因任何原因消失的时刻,然后单击其中一个项目(生成可以处理的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 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 callShow