Rubrik: Controls · ListBox & ComboBox | VB-Versionen: VB2005, VB2008 | 08.12.09 |
Mit nachfolgendem Einzeiler lässt sich die Liste einer ComboBox bei Erhalt des Fokus automatisch aufklappen:
Private Sub ComboBox1_GotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ComboBox1.GotFocus
' ComboBox aufklappen und Liste anzeigen
ComboBox1.DroppedDown = True
End Sub
Soll die ComboBox-Liste erst aufgeklappt werden, wenn der Anwender ein Zeichen in das Eingabefeld eingibt, verwenden wir einfach statt dem GotFocis-Ereignis das KeyPress-Ereignis:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
' ComboBox-Liste bei Eingabe eines Zeichens autom. aufklappen
ComboBox1.DroppedDown = True
End Sub