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

Combo box default

Status
Not open for further replies.

Imbriani

Programmer
Jan 9, 2004
195
US
Does anyone know how to set the default value for a combobox or a listbox? I have a very simple combo box with three values. I want the top value to be the default so the user can just hit enter and select that entry without having to use the down key to select the entry unless another selection is necessary, which is rare. Sounds easy, I know, but I've been unable to find this info in books.

Kathy
 
Don't know if it's the absolute best way but I always use:
Code:
Combo1.Text = Combo1.List(0)
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Try:
Code:
Combo1.ListIndex = 0
This will show you first entry.


Have fun.

---- Andy
 
wonderful! I knew it would be something simple. Does this go best under the GotFocus event?

Kathy
 
Use it where you add the data to your combobox.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Or wherever you need to reset the combo to display the first item.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top