Click to See Complete Forum and Search --> : List boxes with columns
Can somebody please help me
How do you create a list box that uses columns (so that more than one detail of an item added to a list box, can be shown at once).
I would be very grateful if anyone could help.
HeSaidJoe
Dec 30th, 1999, 04:27 AM
'set tab stops in a listbox
'appears as columns
'
Option Explicit
'
Public Declare Function SendMessageArray Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const LB_SETTABSTOPS = &H192
'<<<<< code for form >>>>>
'
Private Sub Command1_Click()
List1.AddItem "Nothing More"
List1.AddItem "Nothing Less"
List1.AddItem "Just A Sample"
Dim r As Long
'set up the tabstops in the listboxes
ReDim TabStop(1 To 3) As Long
'assign values to the tabs for the second third and fourth
'column (the first is flush against the listbox edge ie...0)
TabStop(1) = 80
TabStop(2) = 160
TabStop(3) = 240
'set the tabs
r = SendMessageArray(List1.hwnd, LB_SETTABSTOPS, 3, TabStop(1))
List1.Refresh
List1.AddItem "...A lesson" & vbTab & "in creating" & vbTab & "columns" & vbTab & "in a listbox!"
End Sub
HeSaidJoe
Dec 30th, 1999, 04:29 AM
If you are using a database and datacontrol you can also do this.
'combine two fields from a database
'and display them as one field in a listbox
Dim CombinedFields as String
Dim strSQL as String
strSQL = "SELECT *, FirstField & ', ' _
& SecondField as CombinedFields FROM YourTable;"
Data1.RecordSource = strSQL
DbList1.ListField = "CombinedFields"
kike
Dec 30th, 1999, 05:47 AM
I'm triying to find out how to fill this lists too. If you know something tell me!
The databound controls let you see the data of a table in a multiple column list but if you don't have it in a table u can't do it.
Somebody tell me something about an array, could someone help us!
kike
Jan 1st, 2000, 01:43 AM
Hi!, I finally find out how to do it, it's very simple.
If you have a listBox, the propertie Columns has the value of the number of columns to show up. In runtime just type
ListBox1.AddItem Item1 & vbTab & Item2 & vbTab & Item3
And so on, you just have to insert a Tab between the values you want to put in a List Box. I hope it work for you!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.