• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 23637
  • Last Modified:

Create a multi-column list box?

Hi-

I have a SINGLE list of values that I want to display in a multi-column listbox (i.e. I want to eliminate the vertical scrolling).  I want this multi-column list to display when I click on a control (e.g. a box that says List1) - and when I click on one of the values in the list, I want the list to disappear.

How could I do this in VB6?

With Regards-
Sam
0
SAbboushi
Asked:
SAbboushi
  • 5
  • 5
  • 4
2 Solutions
 
JackOfPHCommented:
better use listview but if you stil want it then try usieng the listbox in the forms 2.0 object library, which I believe supports multiple columns.

Add new components then check the microsoft form 2.0 object library.

0
 
SAbboushiAuthor Commented:
Thanks for your response JackOfPH

Sorry but I don't know how to do what you have suggested - I don't see a listview control in my vb6 toolbox.  Don't know how to proceed when you refer to forms 2.0 object library.
There is an Add-In manager menu option under Add-Ins - but I don't see a menu option for adding new components...

Can you please help with some more detail oriented to my level of ignorance?   ; )

With Regards-
Sam
0
 
JackOfPHCommented:
using listview

goto project menu then select component.

after that select Microsoft windows common control 2.0

then you have listview

same thing microsoft form 2.0 object goto project. select components then microsoft Form 2.0 object library.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JackOfPHCommented:
or you can set the property of listbox to
 list1.columns = 5

this will give you five columns
0
 
SethiCommented:
jackOfPH is right. Here is one great link to learn ListView control:
http://www.developerfusion.co.uk/show/74/

However, if you still want to create a multiple column listbox then here it is:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=32812&lngWId=1
0
 
SAbboushiAuthor Commented:
Thanks for the posts - it looks like list1.columns = 5 is what I need.

I may be wrong, but reading about Listview and muliple column listboxes - it seems these are for displaying multiple columns of related data (i.e. each column has a unique column header) instead of wrapping a single column of data into multiple columns.  Is that true?

list1.columns = 5 does what I want, but "squishes" the columns very close together.  Is there a way that I can control the width of each column (hopefully something OTHER than padding displayed data with spaces...)?
0
 
SethiCommented:
yes...u can monitor the width of columns. Here is an abstract from one of my projects:

With lsvInvoiceDetails
                LockWindowUpdate Me.hWnd
                .View = lvwReport
                .ColumnHeaders.Clear
                .ListItems.Clear
                               
                .ColumnHeaders.Add 1, "ItemNo", "Item No.", 1500
                .ColumnHeaders.Add 2, "Description", "Description", 3000
                .ColumnHeaders.Add 3, "LAB", "LAB", 600
                .ColumnHeaders.Add 4, "Shape", "Shape", 800
                .ColumnHeaders.Add 5, "Clarity", "Clarity", 800
                .ColumnHeaders.Add 6, "Color", "Color", 800
                .ColumnHeaders.Add 7, "CTQty", "CT\Qty", 1200
                .ColumnHeaders.Add 8, "EaPerCt", "Ea Per Ct", 1200
                .ColumnHeaders.Add 9, "TotalPrice", "Total Price", 1500
                .ColumnHeaders.Add 10, "ItemID", "ItemID", 0
End With
0
 
SAbboushiAuthor Commented:
Thanks Sethi-

Your example seems specific for multiple unique columns - which is not my case here (I am also not clear if your post is an example for listbox?):
>I have a SINGLE list of values that I want to display in a multi-column listbox
0
 
SethiCommented:
I think you should use a Grid. MSHflexgrid is a great control that we use for displaying list of values.

BTW, My example was for ListView control.
0
 
SAbboushiAuthor Commented:
Sethi - thanks again.

I was unable to find MSHflexgrid - where do I look?
0
 
SethiCommented:
Go to Project>Component>Microsoft heirarichal Flexgrid control
0
 
JackOfPHCommented:
Well if your'e talking about the Columns property of the listbox, this is how it works...

During development, you set the Columns property to be the number of columns you want displayed. For example, set the Columns property to 5.

*****note ****
The column widths will automatically be set to be ListBox.Width / ListBox.Columns

When you populate the listbox, the listbox will scroll horizontally to display the columns.

Try this:

Add a listbox to a form and set the Columns property to 5.

Adjust the height of the listbox to 1620.   *******set this to fit the text**********

Adjust the width of the listbox to 4095.   *******set this to fit the text**********

put the following code in the form load event:

    Dim iVal As Integer
    For iVal = 1 To 50
        List1.AddItem "Item #" + CStr(iVal)
    Next


and run the program...
0
 
SAbboushiAuthor Commented:
Hi JackOfPH-

I tried your code, but am not sure how this helps me to set the width of each of the columns.  Example: Lets say that only three of my five columns are populated.  There is only about one character of white space between the longest item in column one and the left margin of column two.

Sethi - I was unable to get the flexgrid working - too much of a learning curve without someone providing me the code of how to populate it, etc...

Thanks to you all for your help.

With Regards-
Sam
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now