CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2003
    Location
    India
    Posts
    22

    Back Color in List View and Tree View

    I have to give back color to tree view and list view.

    Ex: For List View

    In first line I want one color and for 2nd line I want another color.
    Satish

  2. #2
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569
    it is not directly possible.
    you would have to use some kind of overlay to do that.
    Mike

  3. #3
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    3

    Exclamation

    Don't listen to Mike ... Can be done with the VB6 TreeView Control. Just requires subclassing.... Have done this myself and works fine. I can email you the project if you want it ...

    The ListView just requires a bitmap. Set the Picture property with a bitmap with alternating colors.

    Hope this helps!

  4. #4
    Join Date
    Apr 2003
    Posts
    1,755

    Smile

    For Trieview, you don't even need to subclass it. Below is the link on how to set the backcolor for the entire Trievew, and how to set the forecorlor for each item.

    Changing Background Colours

    For individual background color for nodes, here's the code
    Code:
    With Me.TreeView1
       .Nodes.Add(Text:="Node1").BackColor= RGB(255, 0, 0)
       .Nodes.Add(Text:="Node2").BackColor = RGB(0, 255, 0)
    End With
    Hope this will help you

  5. #5
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    3

    Exclamation

    What u propose doesn't do the whole line - only the node text. To colour the whole treeview, it's a bit more complicated. Have a look at the attached image.
    Attached Images Attached Images

  6. #6
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569
    Don't listen to Mike ... Can be done with the VB6 TreeView Control. Just requires subclassing....
    Yes... and what exactly do you think "can't be done directly and "some kind of overlay" means, eh?

    You must have heard the word overlay before, as in a thing you lay over something else... as in subclassing, or multi windowing etc...
    Mike

  7. #7
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    3
    Lack of sleep ... but yer ... sorry mate.

    I've the code to do it - just requires a little tweak to do what he wants ... not difficult.

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

Featured