|
-
Jan 7th, 2017, 11:48 AM
#10
Re: (VB6) How can I have a MultiColumn ListBox? (Emergency)
Ahhh, I see that this is a slightly aged thread that got popped.
I also use the ListView extensively, but I also do occasionally use a ListBox to display columnar data.
The following are what I use to do that, along with the vbTab character to separate the columns when adding to the ListBox.
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
'
Public Sub SetOneTabStopInListBox(lst As ListBox, ColWidth As Long)
Dim ColWidths(0 To 0) As Long
'
ColWidths(0) = ColWidth
SetTabStopsInListbox lst, ColWidths()
End Sub
Public Sub SetTabStopsInListbox(lst As ListBox, ColWidths() As Long)
Const LB_SETTABSTOPS = &H192
' A character is approximately 4 "width" units.
' ColWidths() is in character widths of some standard character.
' ColWidths() can be either zero or one based.
' SADLY: This does not work for listboxes with the style set to checkbox.
Dim NumCols As Long
'
NumCols = UBound(ColWidths) - LBound(ColWidths) + 1 ' Calculate the number of columns.
SendMessage lst.hWnd, LB_SETTABSTOPS, 0&, ByVal 0& ' Clear any existing tabs.
SendMessage lst.hWnd, LB_SETTABSTOPS, NumCols, ColWidths(LBound(ColWidths)) ' Set new tabs.
End Sub
Enjoy,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|