Results 1 to 8 of 8

Thread: Listview Forecolor (RESOLVED)

  1. #1

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    Listview Forecolor (RESOLVED)

    For some reason, VB dont want to color an item in a my listview
    I was this code
    VB Code:
    1. .ListItems.Item(i).ListSubItems.Item(1).ForeColor = &HC000&
    2. .ListItems.Item(i).ListSubItems.Item(2).ForeColor = &HC000&
    3. .ListItems.Item(i).ListSubItems.Item(3).ForeColor = &HC000&
    4. .ListItems.Item(i).ListSubItems.Item(4).ForeColor = &HC000&
    5. .ListItems.Item(i).ListSubItems.Item(5).ForeColor = &HC000&
    Strange thing is that he changes the color of the 3rd Culomn (item(2)), but does not change the others.
    what the hell is going on?
    Last edited by Stiletto; Jul 17th, 2003 at 11:57 PM.

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    My stupid comp. I'll restart

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    As I said, your code works for me but here's a sub that I use in one of my apps. Does it make a difference for you?

    VB Code:
    1. Public Sub ColorListviewRow(lv As ListView, RowNbr As Long, RowColor As OLE_COLOR)
    2. '***************************************************************************
    3. 'Purpose: Color a ListView Row
    4. 'Inputs : lv - The ListView
    5. '         RowNbr - The index of the row to be colored
    6. '         RowColor - The color to color it
    7. 'Outputs:
    8. '***************************************************************************
    9.    
    10.     Dim itmX As ListItem
    11.     Dim lvSI As ListSubItem
    12.     Dim intIndex As Integer
    13.    
    14.     On Error GoTo ErrorRoutine
    15.    
    16.     Set itmX = lv.ListItems(RowNbr)
    17.     itmX.ForeColor = RowColor
    18.     For intIndex = 1 To lv.ColumnHeaders.Count - 1
    19.         Set lvSI = itmX.ListSubItems(intIndex)
    20.         lvSI.ForeColor = RowColor
    21.     Next
    22.  
    23.     Set itmX = Nothing
    24.     Set lvSI = Nothing
    25.    
    26.     Exit Sub
    27.  
    28. ErrorRoutine:
    29.  
    30.     MsgBox Err.Description
    31.  
    32. End Sub

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This doesn't affect you, but it's interesting that I found one time that if I want to color a row I can't use the vbBlue constant. I found that I needed to use 16711681 instead which is just one off of vbBlue's value.

  6. #6

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    Nope. Still he colorize what he want to.
    Ive notice that if i have an error and than i resume the program, or if i have Msgbox, or any kind of delay, at the second time it will color the whole row.

  7. #7

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    Originally posted by MartinLiss
    This doesn't affect you, but it's interesting that I found one time that if I want to color a row I can't use the vbBlue constant. I found that I needed to use 16711681 instead which is just one off of vbBlue's value.
    Cool.
    Thing is that he colors some items in that row, but not all of them. (I'm using Green)

  8. #8

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    Stupid VB. You need to refresh the list.
    VB Code:
    1. .Rerfesh

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