Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox ?

Status
Not open for further replies.

75cl

Programmer
Nov 1, 2001
43
US
I dont know whether or this can be done in combobox. Let say i have a combobox contain a few hundreds of item. But I dont want user to click on the dropdown event and select an item. Instead I want them to type in and as long as they start typing, the item start popup until they find their match. Can This be done anyone? Please tell me. This is just something that i am curious to know. Thank you.
 
Hello John,
I am still don't quite understand what do you mean. Would you explain more. Thank You
 
if the style is combobox you can type in it, but it would be better to set to a Dropdownlist an sort it thus when you type jh to find jhon it will automatically goto the first jh instance in list.c If you donot sort it it will goto first j then first h.

i would rather selct the style to list that way it will only go to records that are actually in the list.
 
It is not work. i guess you guys misunderstood me. what i mean is like you know how most of the website have combobox let say contains all the countries. and instead of you select a country by your mouse, you can type in the combobox let say you start to type us it will automatically popup usa, if usa is not the country that you want and as long as you are keep typing new country will popup. I hope this will explain better.
 
It does and will work if the combobox is set up correctly. On the property page of the combobox is a property called "style". There are three settings for the combobox. The default setting is a dropdownlist that allows the user to not only select from the list but also enter text - just like a textbox. The second style looks like a text box, but contains all the items in a list that does not dropdown. The third type which is also a dropdownlist, and this is the one it sounds like you need, does not allow the user to enter text as such, but as you type the closest match to the characters typed is displayed. Make sure you have set the "sorted" property to true. Otherwise this does not work well. The difference between the default style dropdownlist and the other dropdownlist is that the default allows the user to enter text that the combobox sets to its "text" property. If you use the text returned for further processing, which is often why you have a combobox in the first place, the non-default style dropdownlist will force the user to make a valid choice from the list. Otherwise you can and will end up with bogus input. The text returned by the non-default style combobox will only be one of the list or an empty field. Note: The pattern matching is time dependent. It you have for example 20 entries that start with "P", when you type a "P" the first one in the list starting with "P" is displayed. If you quickly type another character it will match as "P?", etc. If you wait a second or two it will go back to matching the first character. I don't know what the time granularity is, but it is sufficent to type several characters in quick succession to match an entry from a VERY long list

Hope this clarifies things some. Dan Grogan
dan@siqual.com

"Absit prudentia nil rei publicae profitur."
Without common sense you ain't gonna have nothing.
 
In Access 2000 there is a combobox with those properties.
It's just an OCX you can import.
That's all.
 
I think this is what you are looking for, I don't know the constants off hand for the combo box, but here is how you do it for the list box.
Code:
Option Explicit

'Start a new Standard-EXE project.
'Add a textbox and a listbox control to form 1
'Add the following code to form1:

Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Integer, ByVal wParam As String, lParam As Any) As Long

Const LB_FINDSTRING = &H18F

Private Sub Form_Load()

    With List1
        .Clear
        .AddItem "RAM"
        .AddItem "rams"
        .AddItem "RAMBO"
        .AddItem "ROM"
        .AddItem "Roma"
        .AddItem "Rome"
        .AddItem "Rommel"
        .AddItem "Cache"
        .AddItem "Cash"
    End With

End Sub

Private Sub Text1_Change()
    List1.ListIndex = SendMessage(List1.hWnd, LB_FINDSTRING, Text1, ByVal Text1.Text)
End Sub
 
ksBrace,
that is exactly what i am looking for. but you would be nicer if you have the code for the combo box. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top