Key Handling, Alt+Down Arrow

J

jason

hi,

I need to trap combination keys Alt+DownArrow in KeyDown events, but without
any success. Here is the code :

private void myTextBox_KeyDown(object sender, KeyEventArgs e)

{

if(e.KeyCode == Keys.Down && e.Alt)

{

MessageBox.Show("Pressed");

}

}



Thanks.
 
M

Morten Wennevik

Hi Jason,

Your code should work. Could you provide us with a small but complete
sample of your code?
 
H

Herfried K. Wagner [MVP]

jason said:
I need to trap combination keys Alt+DownArrow in
KeyDown events, but without any success. Here is the code :

private void myTextBox_KeyDown(object sender, KeyEventArgs e)

{

if(e.KeyCode == Keys.Down && e.Alt)

Try this:

\\\
if ((e.KeyCode == Keys.Down) && ((Control.ModifierKeys & Keys.Alt) ==
Keys.Alt))
...;
///
 
J

jason

The code works only if textbox's parent is a form.

It does not work if textbox is a child control of DataGridColumnStyle.


Thanks.
 

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