0
votes

I have combo box that is bounded to binding source. The problem is when I open drop down in combo box and click up or down keyboard keys it caused binding source to change its position and events start firing, but it shouldn't be so. It should only fire when I press Enter or Tab keys or click on it with a mouse.

What I tried so far is:

I tried to Inherit the text box and handle the events myself

Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
    If Me.DroppedDown Then
        e.Handled = True
    Else
        MyBase.OnKeyDown(e)
    End If
End Sub

but the problem is that the highlight doesn't move anywhere when up or down keys are pressed. I want to mimic the behavior of the mouse when combo box is in drop down mode. When mouse hoovers over the items it highlights current item but does not cause the binding source to change. Thanks.

1

1 Answers

1
votes

I think if you move what you have in SelectedIndexChanged to SelectionChangeCommited, it should do the trick. Whenever you change the index with SelectedIndexChanged, it will auto-fire. SelectionChangeCommited occurs when the final selection is made.