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!

Combo Loading Help!!! 1

Status
Not open for further replies.

savok

Technical User
Jan 11, 2001
303
AT
Here is how I load my combo box...

Do While Not DBRec.EOF
cmbLoc.AddItem DBRec("Name")
cmbLoc.ItemData(cmbLoc.NewIndex) = DBRec("LocID")
DBRec.MoveNext
Loop

now after i load it i need to set the value based on the LocID i have.

Something like cmbLocation.ListIndex = LocID

obviously this doesnt work, help!

thank you.
 
Use the SendMessage API passing CB_FindString as the wMsg parameter. However, you'll have to store the LocID value in the .List(x) property and not the .ItemData(x). You could hide it off the edge of the list by setting a Tab value which is wider than the width of the list by also using SendMessage and passing the LB_SetTabStops parameter.

Alternatively you can use two excellent controls; SBList and SBCombo, which both have .Find methods for searching in the .ItemData(x) property, plus the extremely useful benefit of an .ItemText(x) property for storing hidden strings against each list item in the same way that .ItemData(x) stores a numeric value. Check out for details.

- Andy.
 
hmm thanks, but there has got to be an easier way for something as simple as that. anyone? Perhaps another way of loading the combo?

thank you.!
 
You could try something like the following:

for idx = 0 to cmdLoc.ListCount - 1
if cmdloc.itemdata(idx) = LocID then
cmdloc.listindex = idx
exit for
endif
next idx
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top