无法在 ComboBox 中检测到鼠标右键单击 [英] Unable to detect right mouseclick in ComboBox

查看:24
本文介绍了无法在 ComboBox 中检测到鼠标右键单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的下拉样式的组合框.我想在用户右键单击列表中的项目时打开一个新窗口,但无法检测到发生了右键单击.

I have a ComboBox that is a simple drop down style. I wanted to open a new window when the user right clicks on an item in the list, but am having trouble getting it to detect a right click has occurred.

我的代码:

private void cmbCardList_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right && cmbCardList.SelectedIndex != -1)
    {
        frmViewCard vc = new frmViewCard();
        vc.updateCardDisplay(cmbCardList.SelectedItem);
        vc.Show();
    }
}

如果我改变 e.Button == MouseButtons.Left 整个事情就很好了.有什么办法可以让我按我的意愿工作吗?

If I change e.Button == MouseButtons.Left the whole thing fires off just fine. Any way I can get this working as I intend?

推荐答案

恐怕除非您进行一些严重的黑客攻击,否则这是不可能的.这篇文章将进行解释.

I'm afraid that will not be posible unless you do some serious hacking. This article will explain.

为您报价:

单独控制

以下控件不符合标准的鼠标点击事件行为:

The following controls do not conform to the standard mouse click event behavior:

Button、CheckBox、ComboBox 和 RadioButton 控件

Button, CheckBox, ComboBox, and RadioButton controls

  • 左键单击:单击、鼠标单击

  • Left click: Click, MouseClick

右键单击:未引发单击事件

左键双击:单击,鼠标单击;点击,鼠标点击

Left double-click: Click, MouseClick; Click, MouseClick

右键双击:无点击事件提出

Right double-click: No click events raised

这篇关于无法在 ComboBox 中检测到鼠标右键单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆