I searched everywhere I could think of and couldn't find the syntax for overriding the ProcessDialogKey method. I finally looked at online help and it turned out to be really simple.
Here's the story:
In the online help it shows this syntax:
[C#]
protected override bool ProcessDialogKey(Keys keyData);
Create the method as follows:
protected override bool ProcessDialogKey(Keys keyData)
{
MessageBox.Show("Override: " + keyData);
base.ProcessDialogKey(keyData);
return true;
}
This method intercepts and processes keys that are not intercepted by the KeyPress event.
base.ProcessDialogKey(keyData) takes the keyData and processes it as if it had not been intercepted. For example with this override in place if you press the tab key when your cursor is in a text box the override method will fire, the MessageBox will show and then the base.ProcessDialogKey will continue with normal operation of the tab moving you to the next control. If you press the shift key, as you would expect the override fires but the base process leaves the cursor in the text box.
This all seems so simple once you know it and such a mystery when you don't.
One more mystery put to rest.
Kyle
Enter your message below
Sign in or Join us (it's free).