Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,096 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,844 people online right now. Registration is fast and FREE... Join Now!




ComboBox Complicated List

 
Reply to this topicStart new topic

ComboBox Complicated List, Multiline Items in Combobox

mpretico
16 Jun, 2008 - 04:56 PM
Post #1

New D.I.C Head
*

Joined: 16 Jun, 2008
Posts: 7

||edit: creating in the Office 2003 VB editor

Good evening all,

I'm new to visual basic so I thank anyone for whatever help you have for me. I am creating a form that runs on the opening of a Word template. The form takes the text in the fields and inserts them into their assigned bookmarks.

What I am trying to do is create either a combobox item or split listing with a multiline string of text.

For example,

I would like the combobox to display as an option

Jet1
Jet2
Jet3

And when Jet1 is selected it would insert something similar to the below:

Aircraft Aviation Business Jets Charter, LLC l Charter Services
Chicago Sales Office l 6150 South Laramie Avenue l Chicago, IL 60638 l USA
Tel. +1 773 581 9448 | +1 800 232 5388 l Fax +1 201 624 7338 l www.site.com

I've tried tweaking the below code but I don't know how to break the text into multiple lines.

CODE
aStateList = Split(" AL AK AS AZ AR CA CO CT DE DC FM FL GA GU" _
                      & " HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS" _
                      & " MO MT NE NV NH NJ NM NY NC ND MP OH OK OR PW" _
                      & " PA PR RI SC SD TN TX UT VT VI VA WA WV WI WY")
Me.ComboBox1.List = aStateList
End Sub


Any help would be greatly appreciated. Thanks!

This post has been edited by mpretico: 16 Jun, 2008 - 05:13 PM
User is offlineProfile CardPM
+Quote Post

mensahero
RE: ComboBox Complicated List
16 Jun, 2008 - 07:36 PM
Post #2

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
I think combo box is not suited for that and there is actually a control that has functionality like that. I just can't remember the name; something like a word with "tree", agh I just can't seem to remember.

But In my opinion I think there is a control for that and doing that with a combo box is really hard and I'll bet its gonna be messy.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: ComboBox Complicated List
16 Jun, 2008 - 08:55 PM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Moved to VB.NET forum.

You need to assign the array to the DataSource property of the ComboBox.
CODE

Me.ComboBox1.DataSource = aStateList

User is offlineProfile CardPM
+Quote Post

mpretico
RE: ComboBox Complicated List
16 Jun, 2008 - 09:05 PM
Post #4

New D.I.C Head
*

Joined: 16 Jun, 2008
Posts: 7

Thanks for the suggestions. The code i posted does work for the state list as it is but I need to do something more advanced than that. I am interested in more suggestions like the tree listing but also keep in mind that I'm doing this in the Office editor so I don't think it has as much functionality.

Any suggestions would be greatly appreciated.
User is offlineProfile CardPM
+Quote Post

mpretico
RE: ComboBox Complicated List
14 Jul, 2008 - 03:02 PM
Post #5

New D.I.C Head
*

Joined: 16 Jun, 2008
Posts: 7

I decided instead to make the combobox value equal three strings and to have a label's caption change when the item was selected. That is how i got past the multiline text in the combo box. Thanks for all of your help.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:16AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month