[RESOLVED] ComboBox SelectionChangeCommitted + TAB key
Hi,
I want to handle the event only when a combox's value is committed.
Not when browsing through items using the arrow keys. (SelectedIndexChanged / SelectedValueChanged)
The problem is that SelectionChangeCommitted isn't triggered when finding an item and tabbing out of the control.
Re: ComboBox SelectionChangeCommitted + TAB key
I think I worked it out.
Code:
Dim ComboBoxValueChanged As Boolean = False
Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted
ComboBoxValueChanged = False
'Do Stuff
End Sub
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
ComboBoxValueChanged = True
End Sub
Private Sub ComboBox1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles ComboBox1.PreviewKeyDown
If ComboBoxValueChanged And (e.KeyCode = Keys.Tab Or e.KeyCode = Keys.Escape) Then
ComboBox1_SelectionChangeCommitted(sender, e)
End If
End Sub
Re: [RESOLVED] ComboBox SelectionChangeCommitted + TAB key
Quote:
Originally Posted by
sgrya1
I want to handle the event only when a combox's value is committed.
Not when browsing through items using the arrow keys.
That's a contradiction, because the value IS committed when browsing through items using the arrow keys.