OK. Am I missing something. The following code captures
the cursor keys alright on the form for everywhere except
when the focus is on a DataGrid or AxWebBrowser.
Yes i have set the KeyPreview property on the form to
true. Almost home!
' +++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyEventArgs) Handles
MyBase.KeyDown
If e.KeyCode = 37 Then ' Cursor left
If e.KeyCode = 39 Then ' Cursor right
End Sub
' ++++++++++++++++++++++++++++++++++++++++++++++++
-----Original Message-----
Cool, it works!
Where is the table for all the ChrW(###) codes for
capturing KeyPresses?
I have tried from 1-256 can can't seem to find the
cursorRight/Left/Up/Down indexes.
-----Original Message-----
Set the KeyPreview property on the form to true.
Then form will get all key events and allow you tospecify if you havehandled the event. Do this with the handled property
onthe KeyPress/KeyDown/Key Up events.
Lloyd Sheen
"Bob Achgill" <an*******@discussions.microsoft.com>
wrote in messagenews:8f****************************@phx.gbl... When I use the code for KeyPress to capture pressing a
certain key for processing on a form with no Text Box
it works.
But when I try the same code on my application that
has text boxes it does does not work.
How can I capture the cursor left and right keys for
processing?
Bob
+++++++++++++++
Private Sub Form1_KeyPress(ByVal sender As Object,ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles
MyBase.KeyPress
' The keypressed method uses the KeyCharproperty to check
' whether the ENTER key is pressed.
' If the ENTER key is pressed, the Handled
property is set to true,
' to indicate the event is handled.
If e.KeyChar = Microsoft.VisualBasic.ChrW(65)Then e.Handled = True
MsgBox("The following key was depressed "
+ ChrW(65)) ' Display message that the " " was pressed
End If
End Sub
.
.