ProcessDialogKey isn't called

J

Jim

I'm missing something, because I'm just not understanding this process. I'm
using a Form (no derived controls or derived forms) and I want to catch the
arrow keys. I've got the overridden ProcessDialogKey written (see below),
but it isn't called when I press the appropiate keys. How do I call it??

thanks,
Jim

protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
{
switch (keyData)
{
case Keys.Down:
MessageBox.Show("Down arrow");
break;
case Keys.Up:
MessageBox.Show("Up arrow");
break;
case Keys.Left:
MessageBox.Show("Left arrow");
break;
case Keys.Right:
MessageBox.Show("Right arrow");
break;
default:
break;
}
}
 
R

Roy Osherove

I'm missing something, because I'm just not understanding this process. I'm
using a Form (no derived controls or derived forms) and I want to catch the
arrow keys. I've got the overridden ProcessDialogKey written (see below),
but it isn't called when I press the appropiate keys. How do I call it??

thanks,
Jim

protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
{
switch (keyData)
{
case Keys.Down:
MessageBox.Show("Down arrow");
break;
case Keys.Up:
MessageBox.Show("Up arrow");
break;
case Keys.Left:
MessageBox.Show("Left arrow");
break;
case Keys.Right:
MessageBox.Show("Right arrow");
break;
default:
break;
}
}

Jim.First, you're misssing a return true/false line in the end of the
method.
Second, putting this line on an empty, crispy new c# project form throws
the message boxes just like you want.
SO, the question here, is, "can I see your entire code?"
 

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