How to detect Page Down/Page Up keys, etc.

F

foo

Hello,

I can trap alphanumeric keys wih this code but the event doesn't even fire
when a page down, page up, home, end is pressed. I've overloaded the
OnKeyPress event for the form. The event will fire on alphanumeric keys,
punctuation, etc. Why won't the event fire on Page Up/Page Down keys?
Protected Overrides Sub OnKeyPress(ByVal e As
System.Windows.Forms.KeyPressEventArgs)

Select Case Val(e.KeyChar())

Case Keys.PageDown ' Page Down

....

end function



Thanks,

Bill Nicholson

Cincinnati, OH, USA
 
A

Armin Zingler

foo said:
I can trap alphanumeric keys wih this code but the event doesn't
even fire
when a page down, page up, home, end is pressed. I've overloaded
the OnKeyPress event for the form. The event will fire on
alphanumeric keys, punctuation, etc. Why won't the event fire on Page
Up/Page Down keys? Protected Overrides Sub OnKeyPress(ByVal e As
System.Windows.Forms.KeyPressEventArgs)

Select Case Val(e.KeyChar())

Case Keys.PageDown ' Page Down

...

end function

These keys don't create chars. Use OnKeyDown instead.
 
P

Patrick Steele [MVP]

I can trap alphanumeric keys wih this code but the event doesn't even fire
when a page down, page up, home, end is pressed. I've overloaded the
OnKeyPress event for the form. The event will fire on alphanumeric keys,
punctuation, etc. Why won't the event fire on Page Up/Page Down keys?

For the other keys, you need to override the OnKeyDown method.
 

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