C#,mouseClickEvent不响应鼠标右键单击

发布于 2024-09-07 00:37:37 字数 102 浏览 1 评论 0原文

单击事件不响应鼠标右键单击。该事件适用于 richTextBox。 当我在表单上尝试相同的代码时,它工作正常。

可能是什么问题?

编辑:我使用winforms

on click event doesn't respond to right mouse click. The event is for a richTextBox.
when I try the same code on the form it works fine.

what could be the problem?

EDIT: I use winforms

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

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

发布评论

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

评论(2

清音悠歌 2024-09-14 00:37:37

您需要在 MouseDown 事件上检查它。

private void TextBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
        wasRightButtonClicked = true;
}

You need to check it on the MouseDown event.

private void TextBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
        wasRightButtonClicked = true;
}
与君绝 2024-09-14 00:37:37

Click 和 MouseClick 事件仅由左键单击生成。如果您想检测右键单击,则必须实现 MouseDown 或 MouseUp 事件。

The Click and MouseClick events are only generated by a left-click. If you want to detect right-clicks then you have to implement the MouseDown or MouseUp event.

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