|
-
Nov 15th, 2002, 01:02 AM
#1
Thread Starter
Member
Trapping Arrow Keys
Hi All,
It appears that in VB.Net Microsoft (In their infinite wisdom) has decided to make arrow keys act like the TAB key. In my application I need to know when the arrow keys are pressed when one of my UserControls has focus. Unfortunately, The arrow keys don't even raise the KeyDown event for my UserControl.
How do I get around this little problem?
Alan Liddle
-
Nov 15th, 2002, 09:03 AM
#2
Frenzied Member
You should override the IsInputKey function of the control. Imagining that you have a textbox as a contorl this my help
Code:
Public Class mytextbox
Inherits System.Windows.Forms.TextBox
Protected Overrides Function IsInputKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
Select Case keyData
Case Keys.Left
MsgBox("LEFT") ' Any code can go here
Return True
Case Keys.Right
MsgBox("RIGHT") 'any code can go here
Retrun True
Case Keys.Up
MsgBox("UP") 'any code can go here
Retrun True
Case Keys.Down
MsgBox("DOWN") 'any code can go here
Retrun True
End Select
Return MyBase.IsInputKey(keyData)
End Function
-
Feb 2nd, 2003, 05:11 PM
#3
Addicted Member
vb.net compiler says "Return" not decleared.
-
Feb 2nd, 2003, 05:40 PM
#4
Frenzied Member
Oh sorry,
I just noticed that I have typed some of "Return"s as "Retrun" in the above code.
-
Feb 2nd, 2003, 07:27 PM
#5
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|