I think that the column property is for display purposes only, but in fact
it shows only one set of data.
You can simulate columns by inserting tab characters between 'column' items.
List1.AddItem item1 + Chr$(9) + item2 + chr$(9) + item3
Well, it is not that easy. If the length of your items is variable you
should need to add more tabs after short items in order to alineate the
columns. Sometimes you may prefer truncate long items.
I wrote the following code (just for fun) (Warning: not fully tested)
Option Explicit
Dim LCW() As Integer 'array for the widths of columns
Private Sub Form_Load()
FillList
End Sub
Private Function SetLCW(ParamArray w())
Dim a As Integer
ReDim LCW(UBound(w))
For a = 0 To UBound(w)
LCW(a) = Int(w(a) / 8) + 1
Next
End Function
Private Sub AddListItems(ParamArray items())
Dim r
Dim a As Integer
Dim Output As String
Dim l As Integer
For Each r In items
l = LCW(a) - Int((Len(r)) / 8)
If l > 0 Then
Output = Output + r + String(l, Chr$(9))
Else 'the string is too long, so we must truncate it
Output = Output + Mid(r, 1, LCW(a) * 8) + Chr$(9)
End If
a = a + 1
Next
List1.AddItem Output
End Sub
Private Sub FillList()
SetLCW 20, 6,15
AddListItems "NAME", "NUMBER","NICKNAME"
AddListItems "John", "123","Johnny"
AddListItems "Peter", "2","Saint"
AddListItems "Steven", "722","Sty"
AddListItems "George", "665","GW"
AddListItems "Maximilian", "102","Max"
AddListItems "Ana", "763","Ana"
AddListItems "Alexander, The Greek Conqueror", "398","Magnus"
End Sub
-----Mensaje original-----
De: Manish Jain [mailto:memanishjain@y...]
Enviado el: Domingo, 24 de Junio de 2001 11:00 a.m.
Para: professional vb
Asunto: [pro_vb] Multi column List box
Some one knows how to set a multicolumn list box(Please dont recommend
List View)
I wish the following format
Name Roll No
manish 123
rajesh 124
sanjay 89
mohit 235
How to do this
I tried Column property but was unable to do any thing
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Manish Jain