|
-
Aug 22nd, 2002, 10:04 AM
#1
Thread Starter
Frenzied Member
Tabs in ListBox
VB Code:
Do Until rsClient.EOF
lstResult.AddItem rsClient("LastName") & vbTab & rsClient("FirstName") & vbTab & rsClient("ClientCode")
lstResult.ItemData(lstResult.NewIndex) = rsClient("ClientID")
rsClient.MoveNext
Loop
SearchListTabs(1) = 50
SearchListTabs(2) = 120
SendMessage lstResult.hWnd, LB_SETTABSTOPS, UBound(SearchListTabs) + 1, SearchListTabs(1)
lstResult.Refresh
Why doesn't this work? It only shows the LastName and then the line is blank.
-
Aug 22nd, 2002, 10:06 AM
#2
Frenzied Member
Don't you need to declare everything after the first one (LastName) as 'Sub-Items' ?
-
Aug 22nd, 2002, 10:08 AM
#3
Thread Starter
Frenzied Member
It's a listbox, not a listview.
-
Aug 22nd, 2002, 10:08 AM
#4
no its a listbox not a listview.. i am guessing it is because you are tabbing in it.. try replacing the tabs with " " or something to see if it works
-
Aug 22nd, 2002, 10:10 AM
#5
Thread Starter
Frenzied Member
I thought I needed the tabs in order to set tabs in the SendMessage function.
-
Aug 22nd, 2002, 10:24 AM
#6
actually I just tested and the tabs don't mess it up..
are you saying when you loop the record set it only shows the last name in the listbox?
i tried
VB Code:
lstResult.AddItem "WORLD" & vbTab & "HELLO" & vbTab & "1234"
lstResult.ItemData(lstResult.NewIndex) = "1234"
and it worked fine..
or are you saying that the sendmessage part is not working?
-
Aug 22nd, 2002, 10:26 AM
#7
Thread Starter
Frenzied Member
The data from the recordset works fine.
Yes, It's the SendMessage that's not working.
-
Aug 22nd, 2002, 10:56 AM
#8
Thread Starter
Frenzied Member
-
Aug 22nd, 2002, 11:07 AM
#9
vbgladiator
what does that sendmessage do to the listbox (or supposed to do)?
-
Aug 22nd, 2002, 11:25 AM
#10
You need to set your Tabs BEFORE you populate your Listbox.
VB Code:
'Example:
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 cmdLoadListBox_Click()
'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) = 90
TabStop(1) = 130
TabStop(2) = 185
'clear then set the tabs
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 3, TabStop(0))
List1.AddItem "Big" & Chr(9) & "Brown" & Chr(9) & "Dog"
List1.AddItem "Brown" & Chr(9) & "Big" & Chr(9) & "Dog"
List1.AddItem "Dog" & Chr(9) & "Brown" & Chr(9) & "Big"
List1.Refresh
End Sub
-
Aug 22nd, 2002, 11:38 AM
#11
Thread Starter
Frenzied Member
This is my code:
VB Code:
SearchListTabs(0) = 50
SearchListTabs(1) = 120
Call SendMessage(lstResult.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(lstResult.hWnd, LB_SETTABSTOPS, UBound(SearchListTabs) + 1, SearchListTabs(0))
Do Until rsClient.EOF
lstResult.AddItem rsClient("LastName") & vbTab & rsClient("FirstName") & vbTab & rsClient("ClientCode")
lstResult.ItemData(lstResult.NewIndex) = rsClient("ClientID")
rsClient.MoveNext
Loop
lstResult.Refresh
It still doesn't format the listbox.
-
Aug 22nd, 2002, 11:52 AM
#12
Thread Starter
Frenzied Member
Found the problem.
For some reason my declare line for SendMessage was expecting a string as the 4th argument instead of any.
Thanks.
-
Aug 22nd, 2002, 11:54 AM
#13
I just whipped this together, and it works perfectly
VB Code:
Private Sub Form_Load()
Set Db = OpenDatabase("c:\codelib\codelibrary.mdb")
SQL = "SELECT description, id FROM codeitems WHERE parentid = 1 ORDER BY description "
Set Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
ReDim TabStop(0 To 1) As Long
TabStop(0) = 190
Do While Not Rs.EOF
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 1, TabStop(0))
List1.AddItem Rs(0) & Chr(9) & Rs(1)
Rs.MoveNext
Loop
End Sub
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
|