vb.net different color in listview lines

VB.net – Each listview line in a different color

This is how to make each line in a listview have a different color.

The listview in this example is named “lv”.

                Dim myRow As ListViewItem
                Dim RowCount As Integer = 0
                For Each myRow In lv.Items
                    If RowCount Mod 2 = 0 Then
                        myRow.BackColor = Color.Silver
                        myRow.BackColor = Color.LightGray
                    End If
                    RowCount = RowCount + 1