Results 1 to 3 of 3

Thread: [RESOLVED] ComboBox SelectionChangeCommitted + TAB key

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Resolved [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.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    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
    Last edited by sgrya1; Aug 16th, 2022 at 06:14 AM.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,347

    Re: [RESOLVED] ComboBox SelectionChangeCommitted + TAB key

    Quote Originally Posted by sgrya1 View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width