-
Dec 17th, 2013, 12:40 AM
#1
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
-
Dec 17th, 2013, 01:02 AM
#2
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.
-
Dec 17th, 2013, 02:43 AM
#3
Re: Problem with combo box dropeddown
Originally Posted by jmcilhinney
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
-
Dec 17th, 2013, 03:18 AM
#4
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.
-
Dec 17th, 2013, 03:38 AM
#5
Re: Problem with combo box dropeddown
Originally Posted by Edgemeal
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
-
Dec 17th, 2013, 12:25 PM
#6
Re: Problem with combo box dropeddown
did you consider inserting a neutral item at index 0 in your combobox, for example "Select an item"
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 19th, 2013, 07:31 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|