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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box Question 1

Status
Not open for further replies.

DarkMercenary44

Technical User
May 19, 2000
55
US
How can I make 8 list boxes link to each other so that I only have to use the scroll bar on one of them, can I do this without the delay that a timer makes. And how do I make it so that with anyone of them if I click on something it highlights the corresponding item in the other 7 boxes.

If thats to hard for you to answer then try this it may be easier , how can I make columns in a list box.

And the last question is , how can I make alternating rows of color on a normal list box, I can do it with the SBList custom control, but I have to pay for that one, and I'm just making freeware so why buy it.
 
Question 1.
There is no scroll method of a list box, so I don't see how this can be done - there is a scroll event, which the program can respond to but you cannot make a list box scroll automatically. If this is wrong, then let me know how you have done it.
When you select an item in one list box, on the click event of that list box, loop though the items in that list checking the selected property of the item - true if selected, false if not. When you find one that is selected, set the selected property to true for the same item in the other listboxes:
Private Sub List1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
Exit For ' we have the item selected
End If
Next i
List2.Selected(i) = True
End Sub

Question 2.
Set the Columns property of the list box to the required number of columns.

Question 3.
I don't think this can be done. The backcolor property applies to the whole control, not to the list elements.
 
Question 3.
I have just found out that a ListView control (available from MS Windows Common Controls 6.0 SP3) can do the colour thing.

I have not tried this, but I will.

Simon
 

The ListView control will only do the forecolor. The backcolor property applies to the entire list, not each line. Additionally, the forecolor applies to only the .Text property (1st column). You have to programmatically change the forecolor of each of the subitems.
 
Hi DarkMercenary44,

You can use TopIndex property of the ListBoxs to synchronise more than one list box.

In the Scroll event of the first listbox:

[tt]
Private Sub List1_Scroll()

[tab]List2.TopIndex = List1.TopIndex
[tab]List3.TopIndex = List1.TopIndex

End Sub
[/tt]

This will keep them in step.
[sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br> [/sig]
 
There is a product out from Farpoint called ListPro. This will allow you color changes both background and foreground to the cell level.
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top