Click to See Complete Forum and Search --> : question about listBox
mrz
Jun 26th, 1999, 12:09 PM
i make a listCox, and into it i add stuff from databse file,
question: how can i make a kind of headline to the listBox, make it like a table with two or more columns, i want one column from the dataFile to be displayed in one column of the listBox, and another column in the data file, in another column in the listBox
how can i do that ?
VIKRAMAN.K
Jun 27th, 1999, 02:22 AM
Want to create a simple list box that shows several fields of data? The columns property of the list box does not do this, but you can use this function to do it.
Public Const LB_SETTABSTOPS As Long = &H192
Public 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 DoTabs(lstListBox As ListBox, TabArray() As Long)
'clear any existing tabs
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
'set list tabstops
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, _
CLng(UBound(TabArray)), TabArray(0))
End Sub
First, set up the columns:
Dim Tabs(2) as Long
Tabs(0) = 0
Tabs(1) = 100
Tabs(2) = 200
DoTabs List1, Tabs
Then, add your items:
List1.AddItem "John" & vbTab & "Percival" & vbTab & "Content Editor"
List1.AddItem "James" & vbTab & "Limm" & vbTab & "Senior Editor"
------------------
VIKRAMAN.K
Jun 27th, 1999, 02:25 AM
Want to create a simple list box that shows several fields of data? The columns property of the list box does not do this, but you can use this function to do it.
Public Const LB_SETTABSTOPS As Long = &H192
Public 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 DoTabs(lstListBox As ListBox, TabArray() As Long)
'clear any existing tabs
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
'set list tabstops
Call SendMessage(List1.hWnd, LB_SETTABSTOPS, _
CLng(UBound(TabArray)), TabArray(0))
End Sub
First, set up the columns:
Dim Tabs(2) as Long
Tabs(0) = 0
Tabs(1) = 100
Tabs(2) = 200
DoTabs List1, Tabs
Then, add your items:
List1.AddItem "John" & vbTab & "Percival" & vbTab & "Content Editor"
List1.AddItem "James" & vbTab & "Limm" & vbTab & "Senior Editor"
------------------
mrz
Jun 27th, 1999, 09:13 AM
for some reason this doesnt work, i wanted the listbox to be like a dbgrid, only without the grid. - if it even possible.
vikram.k
Jun 28th, 1999, 11:00 AM
Hi,
I did a small mistake. Replace list1 by lstListBox and put the following statements into a module
Public Const LB_SETTABSTOPS As Long = &H192
Public 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 DoTabs(lstListBox As ListBox, TabArray() As Long)
'clear any existing tabs
Call SendMessage(lstListBox.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
'set list tabstops
Call SendMessage(lstListBox.hWnd, LB_SETTABSTOPS, _
CLng(UBound(TabArray)), TabArray(0))
End Sub
Declare the following statement in General Declaration of a form
Dim Tabs(2) as Long
Then put the following statements into form_load event
Tabs(0) = 0
Tabs(1) = 100
Tabs(2) = 200
DoTabs List1, Tabs
List1.AddItem "Vikraman" & vbTab & "Parthiban" & vbTab & "Aishwarya"
List1.AddItem "Suresh Babu" & vbTab & "Thiyagarajan" & vbTab & "Ganesh"
then execute and get the result whatever you expect.
Hint: -Add a list control into your form
-Size of array tabs mention that how many columns you are going to add
Bye!
------------------
hurgh
May 2nd, 2001, 07:05 PM
1h$@@@@@@@@@@B
BB@@@X@@@@@@@@
ZZ@@ZZtt
~~~
^7*
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.