Solved

Autoselecting the First item in a combo-box

Posted on 1998-08-05
5
149 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.
0
Comment
Question by:dt19643063098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1467986
Combo1.ListIndex = 0
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1467987
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
0
 

Author Comment

by:dt19643063098
ID: 1467988
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.
0
 
LVL 6

Expert Comment

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

0
 

Author Comment

by:dt19643063098
ID: 1467990
Thanks for the help.  If your familiar with Crystal Reports, you might want to look at the other question I submitted.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 73
Error with a code discussed on this page 5 48
Assign a value in Excel V-Basic 3 36
Excel Web Add-in Where is Visual Basic used 9 72
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question