Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding Items to Multi column listbox

Posted on 1998-10-07
7
Medium Priority
?
577 Views
Last Modified: 2011-09-20
I am using a multicolumn listbox, how do I add items to each column?
0
Comment
Question by:whitej8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 400 total points
ID: 1438702
WhiteJ8,
When you are filling the listbox (with .additem), it will not
start filling the other columns until you have filled the first column. Then it begins scrolling horizontally instead of vertically.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1438703
I'm sure it's not the answer you wanted,
The only way you can fill the other columns first is to simulate it by filling the first column with spaces. This, however, can get very messy and isn't very reliable. Also, when you do it this way, the user can click on the rows which contain spaces. That makes it kind of confusing.

For instance(assuming this listbox has 5 rows and 2 columns):

List.additem "First Column"
List.additem " "
List.additem " "
List.additem " "
List.additem " "
List.additem "Second Column"


0
 
LVL 2

Expert Comment

by:BergJC
ID: 1438704
I'm sure it's not the answer you wanted but,
The only way you can fill the other columns first is to simulate it by filling the first column with spaces. This, however, can get very messy and isn't very reliable. Also, when you do it this way, the user can click on the rows which contain spaces. That makes it kind of confusing.

For instance(assuming this listbox has 5 rows and 2 columns):

List.additem "First Column"
List.additem " "
List.additem " "
List.additem " "
List.additem " "
List.additem "Second Column"


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:trillian30
ID: 1438705
If you are using the multicolumn list box from the MS Forms 2.0 Object Library - not a normal listbox - you can fill it using an array which does not require you to fill one column before filling another.  If this is what you had in mind I'll give you the code to do it.
0
 
LVL 1

Expert Comment

by:steve06
ID: 1438706
You should not use the multicolumn option to simulate a listbox which has many columns for each row.

What you should do instead is to use the pre-defined tabulations which exist in the list box. Try:

List1.Additem "John" & chr$(9) & "Doe"
List1.Additem "Jim" & chr$(9) & "Smith"

If you want to modify the tabulation settings, then you have to use the API SendMessage.

Steve.

0
 
LVL 2

Expert Comment

by:BergJC
ID: 1438707
I agree with Steve06, you shouldn't try to use the listbox to simulate multiple rows. That's why I said it wasn't the answer you were looking for. I'd try using another control, possibly the dbGrid, for multicolumn functions.
0
 

Expert Comment

by:trillian30
ID: 1438708
There is a listbox control in the MS Forms Obj 2.0 that supports multiple columns.  Additionally you can specify one column as the "bound column" so when you use the listbox's value property it will automatically pick up whatever is in that column for the specified row.  You can also use different sizes for the different columns.  

This listbox does not simulate multi-columns - it supports multi-columns and is part of VB 5.0 - you just need to add the MS Forms 2.0 Obj Lib component to your toolbox.

Here is a code sample showing how to add items to the multi-column list box:

'column 1, report name
    vReportArray(0, 0) = "Report 1"
    vReportArray(1, 0) = "Report 2"
    vReportArray(2, 0) = "Report 3"
       

'column 2 Report id
    vReportArray(0, 1) = "1"
    vReportArray(1, 1) = "2"
    vReportArray(2, 1) = "3"
       
    listbox1.List() = vReportArray

Hope this helps.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question