Simple Listview Question

Is there a way to make my listview's background color altenrate with 2 colors

Like on some programs a list of something has white blue white blue for each item's background color.

Is there a way to do that so i dont have to have a loop go trhough each item and set its background color



Answer this question

Simple Listview Question

  • rajaraman

    Josh... you know... a really meaningful title for this thread would be:

    ListView Background color.



  • Farmer11243

    There is no shortcut, but looping through the items is easy:

    Dim i As Integer

    Dim j As Integer = 0

    Dim item As ListViewItem

    For Each item In ListView1.Items

        If j = 0 Then

            ListView1.Items(i).BackColor = Color.Blue

            j = 1

        Else

            ListView1.Items(i).BackColor = Color.White

            j = 0

        End If

        i = i + 1

    Next

    Hope this helps,

    Steve Hoag

    Visual Basic Express



  • Simple Listview Question