1,105,456 Community Members

How do I populate multiple column list box?

Member Avatar
BombAppetit
Light Poster
29 posts since Jun 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
lover99509
Newbie Poster
21 posts since Jul 2006
Reputation Points: 5 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
Comatose
Taboo Programmer
2,536 posts since Dec 2004
Reputation Points: 290 [?]
Q&As Helped to Solve: 227 [?]
Skill Endorsements: 34 [?]
Team Colleague
 
0
 

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:

For I = 0 To 300
    List1.AddItem I
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

Member Avatar
BombAppetit
Light Poster
29 posts since Jun 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Eddy Jawed
Newbie Poster
6 posts since Apr 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Try MSFlexiGrid instead, its alot better.

Member Avatar
vba
Newbie Poster
1 post since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

here is the answer - well my technique anyway.

myListBox.ColumnCount = 2

Private Sub AddItems(Text1 As String, Text2 As String)
    myListBox.AddItem (Text1)
    myListBox.Column(1, TraceBox.ListCount - 1) = Text2
End Sub
jksjai
Newbie Poster
1 post since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Thanx a lot.... i was so confused

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article