Adding a row to a multi-column listbox

J

John Austin

I am using the the MS Office listbox in VB6 as it is has more features than
the VB6 version, including multiple columns.

I see that the entire list can be added by setting .Column or .List to a two
dimensional array. The doccumentation suggests that a row can be also be
added using the List or Column properties, but I cant make it work.

How can I add an item to a multicolumn listbox frim a variant array?
 
P

Peter Huang [MSFT]

Hi

I think you may try the code below to add a row with two columns into the
listbox

Private Sub Command1_Click()
ListBox1.ColumnCount = 2
ListBox1.AddItem "Item 1, Column 1"
ListBox1.List(0, 1) = "Item 1, Column 2"
ListBox1.AddItem "Item 2, Column 1"
ListBox1.List(1, 1) = "Item 2, Column 2"
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

John Austin

Thanks, Peter that does the trick!

I thought that you could do something like ListBox1.List(RowNo)=V()

But you code is fine.
 
P

Peter Huang [MSFT]

Hi John,

Thanks for your quickly reply!
And I am glad that my suggestion helps you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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