Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multicolumn ListBox 2

Status
Not open for further replies.

InsaneProgrammer

Programmer
Jan 17, 2001
44
US
I am populating a list box from a database using the following code:
Code:
Do Until MyRS.EOF
    with lstProducts       
            .AddItem MyRS(0)
            .AddItem MyRS(1)
            .AddItem MyRS(2)
            .AddItem MyRS(3)
     MyRS.MoveNext
loop
The data displays in the listbox but in one long column. How do I get it to seperate into multiple columns? I've tried changing the number of columns in properties but that hasn't worked.
 
Sounds like you want to display the fields of a record in one row of a listbox?

Here's one way to do this:


Do Until MyRS.EOF

lstRow = MrRs(0) + Chr$(9) _
MrRs(1) + Chr$(9) _
MrRs(2) + Chr$(9) _
MrRs(3) + Chr$(9)

lstProducts.Additem lstRow
MyRS.MoveNext

Loop



 
oh sorry I see you just want the columns to loop.. well I can think of a lot of cheesy ways to do this but I'm sure you can find something better.
 
You can use several listboxes.
Each data you you add using additem to specific listbox.
After that you have to add several functions, if you click one listbox others would be selsted too.
For three listboxes:
Private Sub listbox1_Click()
listbox2.TopIndex = listbox1.TopIndex
listbox3.TopIndex = listbox1.TopIndex
listbox2.ListIndex = listbox1.ListIndex
listbox3.ListIndex = listbox1.ListIndex
End Sub
Private Sub listbox2_Click()
listbox1.TopIndex = listbox2.TopIndex
listbox3.TopIndex = listbox2.TopIndex
listbox1.ListIndex = listbo2.ListIndex
listbox3.ListIndex = listbox2.ListIndex
End Sub
Private Sub listbox3_Click()
listbox1.TopIndex = listbox3.TopIndex
listbox2.TopIndex = listbox3.TopIndex
listbox1.ListIndex = listbox3.ListIndex
listbox2.ListIndex = listbox3.ListIndex
End Sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top