Get the status of CTRL key in MouseDown event

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
 
A

Allen Anderson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top