Results 1 to 3 of 3

Thread: [2008] Different colors per line in a ListView

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    [2008] Different colors per line in a ListView

    Hi,

    Different colors per line in a ListView

    How can I drew Different colors per line in a ListView ?

    Thanks in advance

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2008] Different colors per line in a ListView

    Like so;

    Code:
            Dim l As New ListViewItem
            l.Text = "AAA"
            'Use this if you want the sub-items to look the same
            l.UseItemStyleForSubItems = True
            l.ForeColor = Color.Red
            l.BackColor = Color.Black
            ListView1.Items.Add(l)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    Re: [2008] Different colors per line in a ListView

    Hi,


    I found the answer:
    Code:
            For index = 0 To ListView.Items.Count - 1
                If index Mod 2 = 0 Then
                    ListView.Items(index).BackColor = Color.LightYellow
                    ListView.Items(index).ForeColor = Color.Blue
                Else
                    ListView.Items(index).BackColor = Color.LightBlue
                    ListView.Items(index).ForeColor = Color.Red
                End If
            Next
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width