Results 1 to 4 of 4

Thread: [RESOLVED] Change Listview Backcolor with a condition

Threaded View

  1. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: Change Listview Backcolor with a condition

    Quote Originally Posted by jmcilhinney View Post
    First up, the default value for the UseItemStyleForSubItems property of a ListViewItem is True so, unless you want to use different Fonts or ForeColors for the subitems, you only have to set the item BackColor, not all the subitems too.

    Secondly, if you test for greater than 6000 first then everything greater than 8000 and whatever else (you have 6000 twice in your post above) will match too, which you don't want.
    vb Code:
    1. Dim backColor As Color
    2.  
    3. Select Case CInt(lvItem.SubItems(4))
    4.     Case Is > 9000
    5.         backColor = Color.Green
    6.     Case Is > 8000
    7.         backColor = Color.Pink
    8.     Case Is > 6000
    9.         backColor = Color.CornflowerBlue
    10.     Case Else
    11.         backColor = SystemColors.Window
    12. End Select
    13.  
    14. lvItem.BackColor = backColor
    Thanks John ,

    actually there is bug
    i modded that code but
    Code:
                        Select Case CInt(item1.SubItems(4).Text)
    
                            Case Is > 9000
    
                            backColor = Color.Green
    
                            Case Is > 8000
    
                                backColor = Color.Pink
    
                            Case Is > 6000
    
                                backColor = Color.Green
    
                            Case Else
    
                                backColor = SystemColors.CornflowerBlue
    
                        End Select
    
    
    
                        ListView3.BackColor = backColor
    actually i'am show listview rows via loop
    when i added that code i get the the backcolor changed on the Listview itself
    but i'am trying to change backcolor of current row in the listview


    @weirddemon,

    i do have only 1 Listview
    weirddemonz

    edit : Fixed now all work Thanks John & weirddemon
    Last edited by killer7k; Nov 19th, 2009 at 07:04 AM.

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