vb.net - 当您 ctrl + 单击 WinForm 中的按钮时运行?

标签 vb.net winforms mouseevent keyboard-events

我正在尝试在用户按住 ctrl 按钮并单击 NotifyIcon 时运行不同的代码。

我的代码不起作用,但我觉得它清楚地解释了我何时尝试这样做。这是在鼠标点击事件下。

        Private Sub NotifyIcon_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles NotifyIcon.MouseClick
        If (e.Modifiers = Keys.Control) Then
            MsgBox("CTRL was pressed !")
        Else
            MsgBox("CTRL was not pressed !")
        End If
        End Sub

最佳答案

不太精通VB,但你也把它标记为C#,你切换过来应该是微不足道的。

private void Form1_MouseClick(object sender, MouseEventArgs e) {
    if (Control.ModifierKeys == Keys.Control) {
        Console.WriteLine("Ctrl+Click");
    }
}

关于vb.net - 当您 ctrl + 单击 WinForm 中的按钮时运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17839869/

相关文章:

wpf - 从 MouseLeftButtonDown 获取 WPF ListBox 项

java - JList MouseMoved 和 MousePressed

.net - 获取网页内容并进行处理(打印或保存到文件)

c# - 从 WinForm 中删除动态添加的控件

c# - MouseLeftButtonUp 不触发

c# - 如何在 Windows 窗体应用程序中获取监视器的屏幕大小以捕获屏幕截图?

c# - 如何在filewatcher中更新文件名

asp.net 在页面之间传递类的实例

vb.net - 努力使童谣条件发挥作用

vb.net - 使用 VB.NET 和 LINQ 的左外连接 null