Columns inside a listbox?
I heard someone mentioning that it's possible to create columns inside a list box? How do i do this?
If it's not possible, then what control do you guys think is the best for creating options box with columns? (like when you put A,B,C,D inside a combo box, but with columns)
Re: Columns inside a listbox?
Yoou can mimic columns in listbox by setting TabStop but better way is substitute ordinary listbox with Listview control.
In case you still want to use Listbox then here is a sample:
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192
Private Sub Command1_Click()
List1.AddItem "Column1" & vbTab & "Column2" & vbTab & "Column3"
List1.AddItem "Column1" & vbTab & "Column2" & vbTab & "Column3"
List1.AddItem "Column1" & vbTab & "Column2" & vbTab & "Column3"
List1.AddItem "Column1" & vbTab & "Column2" & vbTab & "Column3"
End Sub
Private Sub Form_Load()
'set up the tabstops in the list boxes
ReDim TabStop(0 To 2) As Long
'assign some values to the tabs for the second third and fourth
'column (the first is flush against the listbox edge)
TabStop(0) = 60
TabStop(1) = 120
TabStop(2) = 180
'clear then set the tabs
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 3, TabStop(0))
List1.Refresh
End Sub
Re: Columns inside a listbox?
The ListView would be my vote.
Re: Columns inside a listbox?
Thanks!
Sorry but i'm still new... how do i create listview control? it's not in the standard toolbar right? I know i should use "Add components" but which one should i choose? I didn't see listview or something like that..
Re: Columns inside a listbox?
Add Windows Common Controls 6.0 - ListView is part of that library.
1 Attachment(s)
Re: Columns inside a listbox?
Open attachments to see quick sample project.
Re: Columns inside a listbox?
Re: Columns inside a listbox?
This might help as well as RhinoBull's example:
ListView Tutorial