Results 1 to 2 of 2

Thread: [RESOLVED] [02/03] listview colour row problem

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Resolved [RESOLVED] [02/03] listview colour row problem

    Hi guys.

    i am calling the below procedure each time i add a row to the listview.
    the way i see it working as that each time something is added then the rows are coloured dependant on the value of a particualr sub item

    the code:
    Code:
     Private Sub SetRowItemColours()
            Dim lvi As ListViewItem = lstJobs.Items(0)
    
            For i As Integer = 0 To lstJobs.Items.Count - 1 Step 1
                If lvi.SubItems(1).Text = "NA" Then
                    lstJobs.Items(i).ForeColor = Color.Red
                Else : lstJobs.Items(i).ForeColor = Color.Blue
                End If
            Next i
    
        End Sub
    the problem
    when i add the first row the colour woks fine
    BUT
    all the other rows shall remain this forecolor

    what am i doing wrong. i believe that i am not looping properly

    thanks for any help in advance
    it works 60% of the time, all the time.

  2. #2

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: [02/03] listview colour row problem

    GOT IT

    Dim lvi As ListViewItem = lstJobs.Items(0)
    Dim i As Integer = 0

    For Each lvi In lstJobs.Items
    If lvi.SubItems(1).Text = "NA" Then
    lstJobs.Items(i).ForeColor = Color.Red
    Else : lstJobs.Items(i).ForeColor = Color.Blue
    End If
    i = i + 1
    Next
    it works 60% of the time, all the time.

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