Hi All,
I need to color few items in a list box having style as checkbox. I can understand that getting this done is not so easy. But I need to do this for my project. Can i use any other component instead of listbox like listview. can someone pls help me out with this. I tried many codes from google but no success yet..

Ashish

I need to color few items

What's an item? This is pretty vague stuff here.

You want to color the text, the background, an object item?

to accomplish this in an easiest way you can use the listview control.

but first clear me one thing. what did u mean by this :-

I need to color few items in a list box having style as checkbox

after this i can give u some code snippets(if u wish to do so)

regards

Shouvik

list box which diplays its item as a check box. make a lisbox and set its style to Checkbox from the property window and add the elements. You will get the idea. By the way how can i use listview to change the color of first 5 rows to and last 5 rows to red.
any code snippet??

list box which diplays its item as a check box. make a lisbox and set its style to Checkbox from the property window and add the elements. You will get the idea. By the way how can i use listview to change the color of first 5 rows to and last 5 rows to red.
any code snippet??

see the following code. it adds all monthname in a listview and colors first 5 row to blue and the rest to red. for better viewing set its view to lvwreport(right click lv->properties)

Dim i As Integer
Dim li As ListItem

For i = 1 To 12 Step 1
    With ListView1
        Set li = .ListItems.Add(, , MonthName(i))
    End With
Next i

For i = 1 To ListView1.ListItems.Count Step 1
    If i <= 6 Then
        ListView1.ListItems(i).ForeColor = vbBlue
    Else
        ListView1.ListItems(i).ForeColor = vbRed
    End If
Next i

hope u will grab some

regards
Shouvik

This article has been dead for over six months. Start a new discussion instead.