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

VB6 ListView :: Highlighting Selected Rows

Status
Not open for further replies.

RileyCat

Programmer
Apr 5, 2004
124
0
0
US
I have a ListView with Checkboxes = TRUE

What I need to do is to be able to highlight each row that is selected? I know how to highlight one selected row, but am having trouble highlighting every row that is selected with the Check Box.

Ideas?

Stay Cool Ya'll! [smile2]

-- Kristin
 

If you are talking about the ListBox with the Style set to 1 - CheckBox, then you have to have MultiSelect set to 0 - None and you can only highlight one item.

Unless you are using some other control (you mentioned ListView with check boxes) then disregard my post.

Have fun.

---- Andy
 
You wanting to change the forecolor?

The listview has an ItemChecked event.
 
Here is a little sample

Code:
Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
'change the color
            ListView1.ListItems(Item.Index).ForeColor = vbBlack
            Dim i As Integer
            For i = 1 To ListView1.ListItems(Item.Index).ListSubItems.Count
                ListView1.ListItems(Item.Index).ListSubItems(i).ForeColor = vbBlack
            Next i
 
Set the ListView's MultiSelect property to True, then code such as the following will highlight all checked rows:
Code:
[blue]    Dim myItem As ListItem
    For Each myItem In ListView1.ListItems
        myItem.Selected = myItem.Checked
    Next[/blue][
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top