|
-
Jul 18th, 2005, 11:03 AM
#1
[RESOLVED] Columns property of List box - How to use?
I did this long ago - multiple columns in listbox, but now I seem to have forgot how to do it
Can someone please help me with this? How do we use the Columns property of the standard listbox control?
Pradeep
-
Jul 18th, 2005, 11:04 AM
#2
Re: Columns property of List box - How to use?
Why do you want to put yourself through that torture when using a Listview is some much simpler and much easier to programmatically deal with?
-
Jul 18th, 2005, 11:12 AM
#3
Re: Columns property of List box - How to use?
 Originally Posted by Hack
Why do you want to put yourself through that torture when using a Listview is some much simpler and much easier to programmatically deal with?
It is slower than the standard listbox and I'll be frequently adding and removing rows from it.
-
Jul 18th, 2005, 11:16 AM
#4
Re: Columns property of List box - How to use?
Ok, fine. Here is an example of how to use TabStops to set up columns. You will need to play around with widths and stuff like that until it gets you what you need/want.
VB Code:
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 Form_Load()
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
-
Jul 18th, 2005, 11:40 AM
#5
Re: Columns property of List box - How to use?
Thanks a lot Hack,
This would work fine for me.
But I remember I made multi-column list box without using any API's in the past. Now I can't figure how I did it. It was probably someway using the Columns property, but I'm not sure.
I was curious to know what is the Columns property for and how do we use it.
Pradeep
-
Jul 18th, 2005, 11:43 AM
#6
Re: Columns property of List box - How to use?
 Originally Posted by Pradeep1210
Thanks a lot Hack,
This would work fine for me.
But I remember I made multi-column list box without using any API's in the past. Now I can't figure how I did it. It was probably someway using the Columns property, but I'm not sure.
I was curious to know what is the Columns property for and how do we use it.
Pradeep 
I really don't know Pradeep. I used the code I posted for mutliple listbox lines before the ListView came out (or before I learned how to use it, I can't remember which now. ). I'm sure you could find something through Google or MSDN on the Columns property though.
-
Jul 18th, 2005, 11:54 AM
#7
Re: Columns property of List box - How to use?
There was one more thing I was curious about in this forum...
Why can't I rate someone's post who helped me recently and now helped me again.
-
Jul 18th, 2005, 12:07 PM
#8
Re: Columns property of List box - How to use?
My two cents:
The Columns property of the listbox simply enables you to "snake" the items in the list (i.e. take your list of items and show them in "newspaper" columns). The Columns property is NOT intended for showing different columns (fields) of a row (record) of data.
To show different columns of data in each row, the ListView is the best suggestion, as Hack mentioned. To use the standard listbox, you can set up tabs as Hack suggests, or, a low-tech but effective solution is to first use a monospaced font (such as Courier) for the listbox, then format each string of data with the same amount of positions for each field (padding with blank spaces as necessary).
"It's cold gin time again ..."
Check out my website here.
-
Jul 18th, 2005, 12:49 PM
#9
Re: Columns property of List box - How to use?
 Originally Posted by Pradeep1210
There was one more thing I was curious about in this forum...
Why can't I rate someone's post who helped me recently and now helped me again. 
The FAQ for ratings explains it when it says (in part)
You must give reputations to 10 different people before you can come back to the same person again.
-
Jul 20th, 2005, 01:31 AM
#10
Re: Columns property of List box - How to use?
Thanks all !
Problem resolved. 
Pradeep
-
May 21st, 2014, 09:04 AM
#11
Lively Member
Re: Columns property of List box - How to use?
hi
i have a problem gays
i have a text file whit name "Database.txt" inside my program exe file.
my Database.txt info is:
ali*hashemi*0310967600*1363.10.05*90*90128118
reza*hashemi*03109676022*1361.05.08*91*90128119
i how read this file and split by * and show thats in listbox whit Columns?
thanks
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
|