Re: combobox keypress event
Welcome to the forums. :wave:
This works just fine for me
vb.net Code:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
TextBox1.Focus()
End If
End Sub
Re: combobox keypress event
If the breakpoint isn't being hit, then the event isn't being called. What does your entire code block look like? Does it have the Handles on the end of it? compare it to lines 1 & 2 in Hack's sample... if the Handles part is missing, then that's the problem. Did you by any chance cut the combobox from the form and then put it back?
-tg
Re: combobox keypress event
Thank you for your response(s)
I added the event handler by clicking on the keypress event in the properties/events window. So the IDE added the code. I verified that the syntax was correct with 'handles mycombobox.keypress' at the end.
This is curious: when I use keydown instead of the keypress, it recognizes the break point.
Re: combobox keypress event
I have had situations where the KeyUp event was not happening, but I have never heard of the keypress event being skipped.
By the way, could you be intercepting the keypress event at the form level? What I mean by this is that you could have KeyPreview set to true for the form, and be intercepting the keypress and suppressing the control level keypress. Of course, that's a bit improbable, but we might as well rule it out.
Re: combobox keypress event
Hey Shaggy Hiker - I checked the key preview property and it is set false.
In the interest of moving forward with this project, I'm going to code around this for now, and revisit later. There must be some quirk that I'm not grasping. But thanks for your input...