KeyPreview does not intercept keys in Combo Box

  • Thread starter Thread starter Vadim Rapp
  • Start date Start date
V

Vadim Rapp

Hi:

On my form, I have textbox and combo box. Form's KeyPreview = True. It does
work for the textbox, but not for the combo. I.e.

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
me.Text = e.KeyChar
End Sub

does intercept keys pressed in the textbox, but not in the combobox. Is
there any explanation for this?

thanks,

Vadim
 
* "Vadim Rapp said:
On my form, I have textbox and combo box. Form's KeyPreview = True. It does
work for the textbox, but not for the combo. I.e.

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
me.Text = e.KeyChar
End Sub

does intercept keys pressed in the textbox, but not in the combobox. Is
there any explanation for this?

Which version of .NET do you use? AFAIK this is a bug in .NET 1.0.
 
HKW> Which version of .NET do you use? AFAIK this is
HKW> a bug in .NET 1.0.

1.1.4322

Vadim
 
if you use it on the combo iself it wil work (i use that a lot)
Private Sub cboLijn_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles cboLijn.KeyPress

if you want the form keypress events i suggest you use this (from the 'enter
key' thread tnx to the ppl that replied there :)

Turn "KeyPreview ON" for the form before your try this code:


Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then
If Not ActiveControl Is Nothing Then
SendKeys.Send("{TAB}")
End If
End If

End Sub
 
Back
Top