Set Listview Column Color OnPaint?

Dummy1912

Member
Joined
May 14, 2010
Messages
6
Programming Experience
1-3
Hey Guys,

Any body who can helpme with this problem
i want to color my listview columns

see attach file. i have color it with ms paint :)
this is what i want :)

please somebody.

thanks

Dummy1912
 

Attachments

  • Naamloos 3.png
    Naamloos 3.png
    4.2 KB · Views: 44
@jmcilhinney,

Hello and thanks for the reply

can you explain a little bit more please :(
because i don't know how to start.

thanks

Dummy1912
 
[solved]

Yes found it.

here you go guys have fun.

PHP:
For i As Integer = 0 To ListView1.Items.Count - 1
            ListView1.Items(i).UseItemStyleForSubItems = False

       'Set color for the second column
            If ListView1.Items(i).SubItems.Count > 1 Then
                ListView1.Items(i).SubItems(2).BackColor = Color.Green
            End If

       'Set Color for the 4e Column
            If ListView1.Items(i).SubItems.Count > 1 Then
                ListView1.Items(i).SubItems(4).BackColor = Color.Yellow
            End If
Next


Still have question's ask okay.

Dummy11912
 
A For-Each loop give you access to the item without index lookup, and the With statement simplifies access further:
VB.NET:
For Each item As ListViewItem In Me.ListView1.Items
    With item
        .UseItemStyleForSubItems = False
        If .SubItems.Count > 1 Then
            .SubItems(2).BackColor = Color.Green
            .SubItems(4).BackColor = Color.Yellow
        End If
    End With            
Next
 
Back
Top