Results 1 to 5 of 5

Thread: [RESOLVED] Change Color of ListView Item

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2011
    Posts
    92

    Resolved [RESOLVED] Change Color of ListView Item

    I am trying to either change the text or preferably the background color of a listview item if it is checked and a button is pressed.

    I looked at a few older ways of doing it but it doesn't work anymore

    I'm not really sure about how to do this.

    Code:
        Private Sub RemoveSelectedAddressesToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RemoveSelectedAddressesToolStripMenuItem.Click
            '0.0 Exception Handler
            Try
                For Each i As ListViewItem In lstvwEmails.CheckedItems
                    'get the index of the item, remove in array
                    EmailArray.RemoveAt(lstvwEmails.Items.IndexOf(i))
                  'Change color of item so they know it was removed
                 ???????????????????????????????????????????????????
                Next()
            Catch ex As Exception
                MessageBox.Show("Error occured in Form: Main. Function: RemoveSelectedAddressesToolStripMenuItem_Click. Error: " & ex.Message, "Error")
            End Try
        End Sub

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Change Color of ListView Item

    What is the first member that comes up when you place the cursor inside the loop and type:
    Code:
    i.

  3. #3
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: Change Color of ListView Item

    you must look for the ItemDraw Event of the listview

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2011
    Posts
    92

    Re: Change Color of ListView Item

    Quote Originally Posted by ForumAccount View Post
    What is the first member that comes up when you place the cursor inside the loop and type:
    Code:
    i.
    woooooooooow, lol thanks! Sorry, I was thinking it had to be like

    ListView.Items(i).BackgroundColor = blah

  5. #5
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Change Color of ListView Item

    Technically you could do it that way as well. It would just be BackColor instead of BackgroundColor.

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