|
-
Jul 16th, 2006, 01:03 PM
#1
Thread Starter
New Member
KeyDown event has changed it's behaviour
The code below captures a 'Ctrl-A' KeyDown event. Yesterday it worked fine. I've made no changes to it, yet today, it no longer works. The KeyDown event fires, but whereas yesterday, 65 (for 'a') was written to output, now it writes 17 for the control key, even though I'm pressing Ctrl+A. I thought it had something to do with accidentally changing something in the designer details for the form via Find and Replace (not sure how I managed to do that). However, I've rebuilt the form from scratch and it still doesn't work.
Private Sub ListView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListView.KeyDown
If e.Control Then
Console.WriteLine(e.KeyCode)
If e.KeyCode = Keys.A Then
For i As Integer = 1 To ListView.Items.Count
ListView.Items(i - 1).Selected = True Next End If End If
End Sub
Can anybody suggest anything? Thanks in advance.
-
Jul 19th, 2006, 08:47 PM
#2
Re: KeyDown event has changed it's behaviour
If I do that I get a 17 when I depress the Ctrl key and then a 65 when I depress the A key, which is pretty much what you'd expect.
-
Jul 19th, 2006, 09:15 PM
#3
Thread Starter
New Member
Re: KeyDown event has changed it's behaviour
If I press Ctrl, I get 17. If, while holding down Ctrl, I press A, I still get 17. For several days in a row, it used to output 65 when I held down Ctrl+A and therefore execute the code inside the If e.KeyCode = Keys.A Then statement. I swear it did. There are ample code samples out there that use the same structure and in fact, I got it from surfing the web. It worked fine for a week and then died. Has anybody had a similar problem or could anybody even hazard a guess as to what might cause this change in behaviour? I know I did something to my project that broke it, but I can't figure out what. All I know is, I didn't change this bit of code and I don't know where else to look.
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
|