944,120 Members | Top Members by Rank

Ad:
Aug 30th, 2006
0

How do I populate multiple column list box?

Expand Post »
As the title suggest, I don't know how to add item to a multiple column list box. When I do the usual

ListBox1.AddItem "haha"

it only adds to the first column. How do I populate the others?
Columns property has been set to, say, 3. I googled out this issue but none of them return any usable result.
Similar Threads
Reputation Points: 16
Solved Threads: 0
Light Poster
BombAppetit is offline Offline
29 posts
since Jun 2006
Aug 30th, 2006
0

Re: How do I populate multiple column list box?

as i understod from your message is that you want your listbox list to be like this when the ser drop down the list :-
meat milk
google hotmail
..... ....

if its so. you have to concatenate the columns like this

ListBox1.AddItem "haha"& " " & " haha2"

try it i hope this is what you want.
Last edited by lover99509; Aug 30th, 2006 at 11:41 am.
Reputation Points: 15
Solved Threads: 1
Newbie Poster
lover99509 is offline Offline
21 posts
since Jul 2006
Aug 30th, 2006
0

Re: How do I populate multiple column list box?

Setting The Listbox to have multiple columns will not work the way you expect it to. Having a Mult-Column listbox will only show both columns, when the length of the first column is full. To illustrate this, start a new project, and drop a listbox on it. Change it's columns to 3, and add this code to form_load:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. For I = 0 To 300
  2. List1.AddItem I
  3. Next I
As you can see (depending on how "tall" you made the listbox) the first column fills up first, then the second, and third.... so on. In order to do what you want, it will take a bit of crafty programming, using the API. Check this site for further details: http://www.thescarms.com/vbasic/listbox.asp
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Aug 31st, 2006
0

Re: How do I populate multiple column list box?

oh. i tried the loop you posted. it really did populate in multiple columns. more than 3 actually since my box is rather short.
sigh. last time i did in VBA the data source based on query/table, getting it into multiple columns is straightforward. never knew in VB6, with data source being values, is an entirely different story.

anyway thanks for the suggestions
Reputation Points: 16
Solved Threads: 0
Light Poster
BombAppetit is offline Offline
29 posts
since Jun 2006
Dec 21st, 2009
0
Re: How do I populate multiple column list box?
Try MSFlexiGrid instead, its alot better.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Eddy Jawed is offline Offline
6 posts
since Apr 2008
Sep 10th, 2010
0
Re: How do I populate multiple column list box?
here is the answer - well my technique anyway.

myListBox.ColumnCount = 2

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub AddItems(Text1 As String, Text2 As String)
  2. myListBox.AddItem (Text1)
  3. myListBox.Column(1, TraceBox.ListCount - 1) = Text2
  4. End Sub
vba
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vba is offline Offline
1 posts
since Sep 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How to set another DB table to a click()
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: PC to µC via RS232





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC