We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Autoselecting the First item in a combo-box

dt19643063098
on
Medium Priority
164 Views
Last Modified: 2010-04-30
I am sure this has been answered before, but I don't feel like searching through 5000 questions.  How do you autoselect the first item in a drop-down combo box.  I have added all of the items in there, but I want the first item to be pre-selected.
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
Now that I've locked in the answer, to avoid errors in case the list is empty, you should use this code:
If Combo1.ListCount > 0 Then
  Combo1.ListIndex = 0
Else
  Combo1.ListIndex = -1
End If

Author

Commented:
That doesn't allow me to select anything, it autoselects it and then invokes the click event.  I mis-worded the question.  I want the first item to appear, but not be pre-selected.

Commented:
Oh, in that case:
Combo1.Text = Combo1.List(0)
(use the error avoiding code above)

Author

Commented:
Thanks for the help.  If your familiar with Crystal Reports, you might want to look at the other question I submitted.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.