|
-
Aug 6th, 2001, 08:00 PM
#1
very simple... combo boxes
I am a novice, so be kind. lol.
How do you define the contents of a combo box? and where do you do it?
If I had the the VB help files or if the search box @ vbworld.com was working, i wouldn't ask an obviously easy question....
...so thanks a bunch to anyone who can show me.
-
Aug 6th, 2001, 08:20 PM
#2
You could actually add items to a ComboBox during design-time if you like.
Simply click down the List property type an item and press CTRL+Enter and type the next.
If you want to do it thru code, which is more common because often you fill it up with information from a file or database, simply use the AddItem method.
Where you call the AddItem depends when you want to fill the Box but usually in the Form_Load event.
VB Code:
Private Sub Form_Load()
Combo1.AddItem "Monday"
Combo1.AddItem "Tuesday"
Combo1.AddItem "Wendesday"
Combo1.AddItem "Thursday"
Combo1.AddItem "Friday"
Combo1.AddItem "Saturday"
Combo1.AddItem "Sunday"
Combo1.AddItem "Not a fun day"
End Sub
Best regards
-
Aug 6th, 2001, 08:59 PM
#3
Thanks Joacim,
second time tonight you've helped me.
I have just begun developing an application for my office, voluntaril, with very little VB experience.
You can expect some more questions in the next couple of days.
lol. ...and best regards to you. Adam.
-
Aug 6th, 2001, 11:25 PM
#4
PowerPoster
Hi
Don't want to go to crazy on a simple post but just to also state that is good idea to clear combo box before filling... Combo1.Clear... and also to set the ListIndex property after filling it with Additem.... Combo1.Listindex = 0 for eg.
Regards
Stuart
-
Aug 7th, 2001, 08:15 AM
#5
Originally posted by beachbum
Hi
Don't want to go to crazy on a simple post but just to also state that is good idea to clear combo box before filling... Combo1.Clear... and also to set the ListIndex property after filling it with Additem.... Combo1.Listindex = 0 for eg.
Regards
Stuart
That's true but if you fill it in the Form_Load event you don't really need to clear it if you haven't set any items during design-time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|