|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Event for PgUp and PgDn on FormWould 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 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 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 > > Ed,
"Ed Bitzer" <edbit***@yahoo.com> schrieb: Make sure the form's 'KeyPreview' property is set to 'True'.> 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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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/> 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/> > >
Microsoft not content with "dissing" just the Classic VB Developer Army....
Where to find good icons? In-place Updating in Datagrid not working Why doesn't timer tick Accessing Through Newsreader How to get current free physical memory ? modify HTML in code behind How to expose a structure to VB6 from VB.NET? Datagrid problem Multiselect List Box |
|||||||||||||||||||||||