当鼠标移过按钮时如何使某些内容可见?

发布于 2024-09-14 00:47:30 字数 63 浏览 1 评论 0原文

如何显示 PropertyGrid 而不是上下文菜单,以便当用户单击其他位置时,它将隐藏(就像上下文菜单一样)?

How do I show a PropertyGrid instead of a context menu, so when the user clicks somewhere else, it will hide (like a context menu)?

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

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

发布评论

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

评论(1

热情消退 2024-09-21 00:47:30

您可以将注意力的丧失与此操作联系起来。它并不完美(并非会捕获控件外部的所有点击),但每次另一个控件获取焦点时它都会起作用。

propertyGrid1.Leave += (object sender, EventArgs e) => { propertyGrid1.Hide(); };

如果这还不够好,您可以尝试将该操作连接到其他事件,例如表单的 Click 事件。

You could wire the loss of focus to this action. It's not perfect (not all clicks outside the control will be captured), but it will work every time another control grabs focus.

propertyGrid1.Leave += (object sender, EventArgs e) => { propertyGrid1.Hide(); };

If this is not good enough, you could try wiring the action to other events, such as the form's Click event.

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