Get the status of CTRL key in MouseDown event

  • Thread starter Thread starter Boaz Ben-Porat
  • Start date Start date
B

Boaz Ben-Porat

Is there any way to determine if the CTRL key is pressed from a MouseDown
event on a DataGrid ?

TIA
Boaz ben-Porat
DataPharm a/s
Denmark
 
the function you are looking for is Control.ModifierKeys

private void dataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if ( (Control.ModifierKeys & Keys.Control) == Keys.Control )
Debug.WriteLine( Control.ModifierKeys.ToString() );
}

Thats the relevant code you need. Note, if you don't AND the
ModifierKeys with the key you want you won't be able to tell if
Control is pressed when other modifier keys are pressed also.

-Allen Anderson
http://www.glacialcomponents.com
 
Back
Top