Home All Groups Group Topic Archive Search About

Event for PgUp and PgDn on Form

Author
6 Apr 2005 11:47 AM
Ed Bitzer
Would like to use PgUp and PgDn from a Form event.  Have successfully been
able to use the Enter key as an event unique event from a textbox using the
boxes KeyChar event and e.KeyChar = Microsoft.VisualBasic.ChrW(13) but
search as I may through Help I have not been able to find the keycodes for
PgUp or PgDn or confirm which key event is appropriate. Trial and error is
getting me no where<g>.

Ed

Author
6 Apr 2005 12:22 PM
Crouchie1998
Add a textBox & then add this code:

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

If e.KeyCode = Keys.PageDown Then
   MessageBox.Show(e.KeyValue)
End If

If e.KeyCode = Keys.PageUp Then
   MessageBox.Show(e.KeyValue)
End If

End Sub

PageUp = 33
PageDown = 34

Crouchie1998
BA (HONS) MCP MCSE
Author
6 Apr 2005 8:19 PM
Ed Bitzer
Crouchie,  Works as advertised for a textbox but I was looking for a Form
event.  I have several textboxes on my form and need the key event to do
some work that reloads all the boxes.  If I place the example code under the
KeyDown event for the Form nothing happens.  Suspect that is something to do
with the focus which remains in the textbox and the Form event is never
fired.

Ed


Show quoteHide quote
"Crouchie1998" <crouchie1998@spamcop.net> wrote in message
news:OFcByNqOFHA.1392@TK2MSFTNGP10.phx.gbl...
> Add a textBox & then add this code:
>
> Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
>
> If e.KeyCode = Keys.PageDown Then
>   MessageBox.Show(e.KeyValue)
> End If
>
> If e.KeyCode = Keys.PageUp Then
>   MessageBox.Show(e.KeyValue)
> End If
>
> End Sub
>
> PageUp = 33
> PageDown = 34
>
> Crouchie1998
> BA (HONS) MCP MCSE
>
>
Author
6 Apr 2005 8:35 PM
Herfried K. Wagner [MVP]
Ed,

"Ed Bitzer" <edbit***@yahoo.com> schrieb:
> Crouchie,  Works as advertised for a textbox but I was looking for a Form
> event.  I have several textboxes on my form and need the key event to do
> some work that reloads all the boxes.  If I place the example code under
> the KeyDown event for the Form nothing happens.  Suspect that is something
> to do with the focus which remains in the textbox and the Form event is
> never fired.

Make sure the form's 'KeyPreview' property is set to 'True'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
6 Apr 2005 9:09 PM
Ed Bitzer
Hefried,

That is what I was missing - and once you clued me in I admit I now see in
the Help files.  I missed four times before.  Still have not found the ident
of all the various special keys but trial with a message box will locate
their number, but would be nice to have their names (although this was to
obvious PgDn an PgUp - not even vbPgUp.

Show quoteHide quote
Ed"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:OPRsnguOFHA.3280@TK2MSFTNGP10.phx.gbl...
> Ed,
>
> "Ed Bitzer" <edbit***@yahoo.com> schrieb:
>> Crouchie,  Works as advertised for a textbox but I was looking for a Form
>> event.  I have several textboxes on my form and need the key event to do
>> some work that reloads all the boxes.  If I place the example code under
>> the KeyDown event for the Form nothing happens.  Suspect that is
>> something to do with the focus which remains in the textbox and the Form
>> event is never fired.
>
> Make sure the form's 'KeyPreview' property is set to 'True'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
6 Apr 2005 10:09 PM
Ed Bitzer
Hefried,  Found the listing of key codes under key code constants - gives
the old VB code and the new Net codes.  Of course can not explain why I did
not find before.

Ed

Show quoteHide quote
"Ed Bitzer" <edbit***@yahoo.com> wrote in message
news:OyHqkzuOFHA.2532@TK2MSFTNGP09.phx.gbl...
> Hefried,
>
> That is what I was missing - and once you clued me in I admit I now see in
> the Help files.  I missed four times before.  Still have not found the
> ident of all the various special keys but trial with a message box will
> locate their number, but would be nice to have their names (although this
> was to obvious PgDn an PgUp - not even vbPgUp.
>
> Ed"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:OPRsnguOFHA.3280@TK2MSFTNGP10.phx.gbl...
>> Ed,
>>
>> "Ed Bitzer" <edbit***@yahoo.com> schrieb:
>>> Crouchie,  Works as advertised for a textbox but I was looking for a
>>> Form event.  I have several textboxes on my form and need the key event
>>> to do some work that reloads all the boxes.  If I place the example code
>>> under the KeyDown event for the Form nothing happens.  Suspect that is
>>> something to do with the focus which remains in the textbox and the Form
>>> event is never fired.
>>
>> Make sure the form's 'KeyPreview' property is set to 'True'.
>>
>> --
>> M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>> V B   <URL:http://classicvb.org/petition/>
>
>