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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activating drop down list box

Status
Not open for further replies.

amills

Programmer
May 30, 2003
22
US
I have a text box and list box on my form. What I want to do is open the list box and position it to the record that most closely matches what the user typed in the text box.

What I need to know, I guess, is besides clicking on the list box arrow, can I open it with a piece of code.


Andy
 
Try this:

lcMyMatch="MyMatch"

thisform.combo1.value=lcMyMatch &&set matching value
thisform.combo1.setfocus
KEYBOARD '{F4}' &&causes drop down
 
Sorry, I was thinking combobox. This should work on a listbox:

lcMyMatch="MyMatch"

lnMatchFound=1
FOR x= 1 TO LEN(lcMyMatch)
lcMyvaluePart=UPPER(LEFT(lcMyMatch,m.x))
FOR y = 1 TO THISFORM.list1.LISTCOUNT
IF UPPER(ALLTRIM(THISFORM.List1.ListItem(m.y)))=lcMyvaluePart
lnMatchFound=m.y
ENDIF
ENDFOR
ENDFOR
THISFORM.List1.ListItemId=lnMatchFound
 
Hi

This is a copy from the code of Slighthaze. This is very nice code and credits to Slighthaze.

1. Put in the List1.InteractiveChange

thisform.text1.value = this.value
thisform.text1.refresh()

2. Put this in the Text box for which the list box is looked up.
text1.interactivechange

LOCAL nCnt, sSearchFor, nLen
sSearchFor = ALLTRIM(this.value)
nLen = LEN(sSearchFor)
FOR nCnt = 1 TO ThisForm.List1.ListCount
IF sSearchFor == LEFT(ALLTRIM(ThisForm.List1.List(nCnt)),nLen)
thisform.List1.Selected(nCnt) = .t.
thisform.List1.refresh()
EXIT &&Found one
endif
ENDFOR
*****************************************
You can see a working example in
Incremental Search - Like Help Index
faq184-3842 (If you find this good, do your evaluation on the referred FAQ).

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top