Link to home
Start Free TrialLog in
Avatar of ndb
ndb

asked on

Advanced ComboBox select ...

In the advanced combobox (the one where you can set more then one column), how can I select an item where the second column equals a specific item?
I fill the combobox with the following items:
"Test1", "1"
"Test2", "2"
"Test3", "3"
I want to select the item where the 2 second column has the value 3.
Avatar of blwatkins
blwatkins

I can tell you how, but let me know what control you are using, I remember doing it, but I can't find the control I did it with.


Avatar of ndb

ASKER

It's the ComboBox that is delivered with Microsoft Forms 2.0 (fm20.dll).
Are there any properties like Items or stuff like that???

In Delphi we use something like this

for i := 0 to Combo.Items.Count - 1 do
begin
  if Combo.items.Strings[i] = '3' then
    Combo.itemIndex := i;
end;

Hope this helps a bit....I don't know what properties your combo uses, otherwise I would have translated this code to VB...If you cam tell me what similar properties does your combo uses I might be able to help you.. =)

Regards,
Viktor Ivanov
Avatar of ndb

ASKER

It uses list and listindex ...
Avatar of ndb

ASKER

Your answer works. This is the code:

    For i = 0 To ComboBox1.ListCount - 1
        If ComboBox1.List(i, 1) = Text1.Text Then
            ComboBox1.ListIndex = i
        End If
    Next i

I'm glad it worked :)

Regards,
Viktor Ivanov
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial