鼠标右键单击 propertyGridControl 不起作用
我正在处理 propertyGridControl 上的 Click 和 MouseClick 这两个事件,但是当我用右键单击时没有任何反应 - 它只捕获左侧。
private void propertyGridControl_Click(object sender, EventArgs e)
{
int i = 0;
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
MessageBox.Show("right");
}
}
如何捕获鼠标右键?
I am handling both events Click and MouseClick on propertyGridControl but when I click with right button nothing happens - it catches only left.
private void propertyGridControl_Click(object sender, EventArgs e)
{
int i = 0;
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
MessageBox.Show("right");
}
}
How to catch right mouse click?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经检查了 MouseClick 事件的工作原理,但没有看到此问题。事件已正确引发。我检查了 PropertyGridControl 10.2.5(最新版本)。我只能想象您正在网格编辑器内单击。在这种情况下,鼠标和键盘事件由就地编辑器而不是网格管理。要捕获此事件,您可以使用以下代码:
我还有一个想法。如果设置了控件的 ContextMenuStrip 属性,则按下鼠标右键时不会引发 MouseClick 事件。是你的情况吗?解决方案很简单 - 处理控件的 MouseDown 事件。
I have checked how the MouseClick event works and do not see this issue. The event is correctly raised. I've checked 10.2.5 (latest version) of the PropertyGridControl. I can only imagine that you are clicking inside the grid's editor. In this case, mouse and keyboard events are managed by the in-place editor and not the grid. To catch this event, you may use the following code:
I have just one more idea. If the control's ContextMenuStrip property is set, the MouseClick event is not raised if the right mouse button is pressed. Is it your case? The solution is easy - handle the control's MouseDown event.