AddItem with multi-column listBox

G

Guest

Greetings everyone
I'm trying to learn something about list boxes. I have suceeded with loading
a 2 column listBox with a 2 dimensional array but would be interested to know
how to use AddItem. Let's say I just want to load "dog" and "cat" into the
first row of a 2 column list box using AddItem without building an array
first. Please give me some example code
TIA
 
B

Bob Phillips

With ListBox1
.AddItem "dog"
.List(.ListCount - 1, 1) = "cat"
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
L

Leith Ross

Hello David,

The AddItem method inserts a single Row into the ListBox. The
ColumnCount property sets the number of Columns. You cna then set the
individual columns using the Column property. The code example shows
how to add the data without creating an Array. You can use the Column
property in your code to get or set a Column Value in a given row.
Remember Line, Column, and Row numbers start at zero.

COLUMN PROPERTY FORMAT:
Column(<-column number->, <-row number->)


CODE EXAMPLE:
With ListBox1
ColumnCount = 2
AddItem
Column(0, 0) = "Cat"
Column(1, 0) = "Dog"
End With


CHANGE A COLUMN VALUE:
ListBox1.Column(1, 0) = "Rat"



Sincerely,
Leith Ross
 
G

Guest

Thanks Leith, Bob & Tom,
I've got it now, the 'penny has dropped'
I couldn't see the steps: first add a row, then populate it. I was trying to
populate as part of the AddItem method
Much appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top