Hey Sharon, if you're using the KeyDown event try this.
private void yourKeyDownEvent(object sender, KeyEventArgs e)
{
if(e.Control && e.Equals(Keys.A))
{
// your code here
}
}
Thanks for try Justin,
But when the CTRL key is pressed down --> the event is fired, but the A key
event is not firing the event because the CTRL key is still pressed.
I event changed the code to:
private void OnDataGridKeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if( e.Equals(Keys.A) )
{
if( e.Control ) // It never gets in here !!!
{
// Some code...
}
}
}
I hope there is a solution for that.
------
Thanks
Sharon
Justin Creasy - 22 Dec 2005 17:26 GMT
Hey Sharon, sorry about that, I thought I saw it work but I'm doing it
now and it's not working.
I did some code awhile ago to do something like this but I can't seem
to find it. What you have to do is override some system commands
because you won't be able to use KeyDown or KeyPress. Once the control
key is it, pressing another key will not fire the keyDown event. I'll
look around some more, but for now I would focus on looking for the
lower level functions that get called when system keys (control, alt,
shift, etc.) are pressed. I'll post again if I find what I'm talking
about. good luck
rossum - 28 Dec 2005 20:26 GMT
>Thanks for try Justin,
>But when the CTRL key is pressed down --> the event is fired, but the A key
[quoted text clipped - 18 lines]
>Thanks
>Sharon
Try overriding the ProcessDialogKey event:
bool ProcessDialogKey(Keys keyData)
For Ctrl-A use
if (keyData == Keys.Control | Keys.A) ...
or else
switch (keyData) { case Keys.Control | Keys.A: ...
Return true if you have processed the key, otherwise return
base.ProcessDialogKey(keyData) to give the rest of the system access
to the keystrokes you are not handling.
rossum
--
The ultimate truth is that there is no ultimate truth