Working out if Control button is down in MouseDown event

  • Thread starter Thread starter JezB
  • Start date Start date
Hi JezB
In MouseDown handler check the Control.ModifierKeys static property here you
can find the states of ALT, CTRL and SHIFT keys.

HTH
B\rgds
100
 
You mean something like,
if ((ModifierKeys & Keys.Control) == Keys.Control) //check if Ctrl key was
pressed, note bitwise &

cheers!!

--Saurabh
 
How can this be done ? There's no Keys attribute in MouseEventArgs.

System.Windows.Forms.Control has a static 'ModifierKeys' property you can
access:

e.g.

using System.Windows.Forms;

....
if ( Control.ModifierKeys == Keys.Control )
{
// CTRL key was pressed (and no other modifier)
}
....

n!
 
Use the static ModifierKeys property of the Control class:

if (Control.ModifierKeys == Keys.Control)
{
// then the Ctrl key is down.
}
 
Typical !! Loads of people answer when you find the answer yourself - when
you are really stuck no-one gives a solution !! hehe
 
* "Tim Wilson said:
Use the static ModifierKeys property of the Control class:

if (Control.ModifierKeys == Keys.Control)
{
// then the Ctrl key is down.
}

If you want to check if the control key is down even when other modifier
keys are down, use this code:

\\\
If Control.ModifierKeys And Keys.Control Then
...
End If
///
 
Back
Top