SAbboushi
asked on
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
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
ASKER
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
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
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.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
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...)?
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...)?
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
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
ASKER
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
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
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.
BTW, My example was for ListView control.
ASKER
Sethi - thanks again.
I was unable to find MSHflexgrid - where do I look?
I was unable to find MSHflexgrid - where do I look?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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...
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...
ASKER
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
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
Add new components then check the microsoft form 2.0 object library.