Run when when you ctrl + click a button in a WinForm?
keyboard-events, mouseevent, vb.net, winforms
Solution
Not well versed in VB, but you tagged this as C# as well, should be trivial for you to switch over.
private void Form1_MouseClick(object sender, MouseEventArgs e) {
if (Control.ModifierKeys == Keys.Control) {
Console.WriteLine("Ctrl+Click");
}
}
Problem
I'm trying to run a different code when a user hold down the ctrl button and clicks on the NotifyIcon. My code doesn't work, but I feel it clearly explains when I'm trying to do. This is under a Mouse Click Event. ``` 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 ```