Results 1 to 7 of 7

Thread: Problem with combo box dropeddown

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Problem with combo box dropeddown

    I basically am having a few issues with the combo box ...

    Here's the situation:
    I have a combo box looking up values from an extensive database across the internet on my server... so when you enter some text a thread starts after one second of no input, gets the top 10 results from my server based on the users input and if the combo box still has focus drops down the combo box list with the results...

    The problem is this:
    If the user has entered pe and the server has returned the list: pea, peach, pecan ; when .dropeddown=true is called it automatically selects the "pea" item since it is the first...

    My question is how can I show the drop down without selecting the first matching item in the list?? ... I can't believe that I cannot figure this one out!

    Thanks in advance,
    Kris

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

    Re: Problem with combo box dropeddown

    There is no way to stop that because that's how the ComboBox works. If you had the items in the drop-down list to start with, typed in the text and then clicked the drop-down button yourself then the same thing would happen. You could get the current text before dropping the list and then reset it afterwards but I think that you may find that the cursor goes a bit haywire when you do that. It would be nice if you could do away with the ComboBox and use a TextBox and its AutoComplete properties, but I'm not sure if you can manually display the list in that case.

  3. #3

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Problem with combo box dropeddown

    Quote Originally Posted by jmcilhinney View Post
    There is no way to stop that because that's how the ComboBox works. If you had the items in the drop-down list to start with, typed in the text and then clicked the drop-down button yourself then the same thing would happen. You could get the current text before dropping the list and then reset it afterwards but I think that you may find that the cursor goes a bit haywire when you do that. It would be nice if you could do away with the ComboBox and use a TextBox and its AutoComplete properties, but I'm not sure if you can manually display the list in that case.
    I was thinking that ... but also thought that since there is now way (that I know of either) of showing the AutoComplete that this way was not easily possible either, this is why I went with the combo box in the first place.


    Kris

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Problem with combo box dropeddown

    Not sure I follow, but you can't simply do something like,...?
    Edit - another try..
    Code:
    With ComboBox1
        Dim cboText = .Text            ' save users text
        Dim cartPos = .SelectionStart  ' save caret position
        .DroppedDown = True            ' drop down
        .SelectedIndex = -1            ' reset index
        .Text = cboText                ' restore users text
        .SelectionStart = cartPos      ' restore caret pos.
    End With
    Last edited by Edgemeal; Dec 17th, 2013 at 03:27 AM.

  5. #5

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Problem with combo box dropeddown

    Quote Originally Posted by Edgemeal View Post
    Not sure I follow, but you can't simply do something like,...?
    Edit - another try..
    Code:
    With ComboBox1
        Dim cboText = .Text            ' save users text
        Dim cartPos = .SelectionStart  ' save caret position
        .DroppedDown = True            ' drop down
        .SelectedIndex = -1            ' reset index
        .Text = cboText                ' restore users text
        .SelectionStart = cartPos      ' restore caret pos.
    End With
    Tried it already ... doesn't work ... appears to but when you press the next key it clears the text box as it still thinks that all of the text is selected.

    Kris

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,467

    Re: Problem with combo box dropeddown

    did you consider inserting a neutral item at index 0 in your combobox, for example "Select an item"

  7. #7

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Problem with combo box dropeddown

    Yes ... I still had issues with it though ... it had to be the same text as what was in the combo ... and then there was issues where it would select the text ... I reset the selection to what was selected before it was dropped down ... and it still thought it was selected... pressing a button when it was dropped down deleted all the text and replaced it with the key you pressed... even though the cursor appeared @ the end..

    Anyway I just changed the way I was doing it ... don't use a combo box @ all now!

    Kris

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