-
Trapping arrow key strokes in an MDI form
How can the arrow keys be trapped in an MDI form? Seems these are the only keys that are not usable. Something like this doesn’t work as they would in a regular form.
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Right Then
'***Code ***
End If
If e.KeyData = Keys.Left Then
'***Code ***
End If
End Sub
Thanks for any help you can provide.
-
I also have the same question and really, I would be very grateful for the quick answer, cuz now this inconvenience stops my work)) Thanks in advance!
-
Instead of keycode try keyvalue
Code:
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyValue = Keys.Left Then
*****Whatever Herer*****
End If
End Sub
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Gee Hack, you had me excited there for a moment. I noticed right off at the end of your SUB procedure you had “MyBase.KeyDown” where mine was “Me.KeyDown”. I thought this is the answer. As it turns out, it still doesn’t work. I had tried “Key.Value” before, but I was sure your “MyBase” was going to do it. Like Britney92, my project is at a stand still until something is found. Thanks for your help.
-
This works just fine for me
Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyValue
Case Keys.Left
MessageBox.Show("You hit the left arrow key")
Case Keys.Right
MessageBox.Show("You hit the right arrow key")
Case Keys.Up
MessageBox.Show("You hit the up arrow key")
Case Keys.Down
MessageBox.Show("You hit the down arrow key")
End Select
End Sub
You do have KeyPreview set to True, right?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Thanks Hack for your help. I tried testing your last code and it worked fine in a form by itself, but when I tried it within the program I’m working on it doesn’t work at all. When pressing the arrow keys it doesn’t even go into the KeyDown procedure at all, but does when all other keys are pressed. Do you have any ideas what may be causing this? I really appreciate your help.
-
Hack, as I said in my previous post, the code works fine, but not within my program. I did some more testing again and it seems that the code will work until a child form becomes present and then the arrow keys will stop functioning. Just thought I'd throw that into the mix.
Similar Threads
-
Replies: 1
Last Post: 04-24-2009, 12:12 AM
-
Replies: 6
Last Post: 04-23-2009, 05:41 AM
-
By craver06 in forum VB Classic
Replies: 10
Last Post: 02-06-2008, 12:12 PM
-
Replies: 1
Last Post: 08-06-2007, 09:36 PM
-
By brouse in forum VB Classic
Replies: 2
Last Post: 07-11-2007, 10:47 AM
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks