
How to use tabs in a listbox?
Hello!
I assume you want to do something like this:
ListBox.AddItem Text1 & chr(8) & Text2 & chr(8) & Text3
To line up the columns you have to set tabstops into your listbox. You
must you the API function SendMessage to do this: Below follows an
example that works in either 16 and 32 bits environment:
'Put this code in a .bas file which you add to your project
#If Win32 Then
Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
As Long) As Long
Public Const LB_SETTABSTOPS = &H192
#Else
Declare Function SendMessage Lib "User" (ByVal hwnd As Integer,
ByVal msg As Integer, ByVal Wp As Integer, Lp As Any) As Long
Public Const WM_USER = &H400
Public Const LB_SETTABSTOPS = WM_USER + 19
#End If
'Here is the code to set tabstops.
Dim lngRet As Long
'Set tabstops
#If Win32 Then
ReDim arrTabs(0 To 2) As Long
#Else
ReDim arrTabs(0 To 2) As Integer
#End If
arrTabs(0) = 80
arrTabs(1) = 300
arrTabs(2) = 301
lngRet = SendMessage(List1.hwnd, LB_SETTABSTOPS, 3, arrTabs(0))
Hope this helps!
Ulf Erik Forsbakk