Plex 2E

Expand all | Collapse all

Change Background of Treeview

  • 1.  Change Background of Treeview

    Posted Mar 18, 2016 07:03 AM

    Hi

     

    I tried to change the background of a treeview. Does someone know if it's possible? We are using Microsoft TreeView Control, version 6.0.

     

    Thank you in advance

    Markus



  • 2.  Re: Change Background of Treeview
    Best Answer

    Posted Mar 18, 2016 02:57 PM

    Hi Markus,

     

    Assuming you are trying to change the background color of a treeview.

     

    Try this C++ sourcecode.

     

    HWND hWnd = ObPanelAPI::GetControlHandleByName("TreeView1");

    SendMessage(hWnd , TVM_SETBKCOLOR , 0 , 0x0000FFFF );

     

     

    Regards

    AA



  • 3.  Re: Change Background of Treeview

    Posted Mar 18, 2016 04:36 PM

    won't say can't but VB Helper: HowTo: Change a TreeView control's background color does say it does not work for version 6



  • 4.  Re: Change Background of Treeview

    Posted Mar 18, 2016 04:54 PM

    The above post is infact for version 6.

    It works for both version 5 and 6.

     



  • 5.  Re: Change Background of Treeview

    Posted Mar 21, 2016 03:03 AM

    AA I think you need to load the tree to see what the articles are highlighting are the issues with TVM_SETBKCOLOR and Microsoft TreeView Control, version 6.0 as opposed to version 5.0

    Capture.PNG



  • 6.  Re: Change Background of Treeview

    Posted Mar 21, 2016 06:23 AM

    Thank you  ashfaq.m.ahmed  and GeorgeJeffcock

     

    I have to agree with GeorgeJeffcock . It works fine with version 5, but not with version 6. In version 6 the background of the text doesn't change.

    TreeviewBakcground.jpg

    Unfortunately I need version 6 for the possibility to set the text to bold, this doesn't work with version 5 (or I didn't find how)



  • 7.  Re: Change Background of Treeview

    Posted Mar 21, 2016 08:48 AM

    Hi Markus,

     

    Node.Bold =  True works only in ver 6, property not supported in ver 5.

     

    In version 6.

    • If you are not using rootlines.
    • After setting the backcolor
    • you need to set node backcolor
    • hide and show treelines or/and change the style and restore

     

     

    'Change bgColor of the node

        For Each nNode In TreeView1.Nodes

            nNode.BackColor = RGB(255, 255, 0)

        Next

     

        TreeView1.LineStyle = 0

        TreeView1.Style = 0 ' tvwTreelinesText   Style 4.

        TreeView1.BorderStyle = 1

     

        'change treeview style

        'TreeView1.LineStyle = 1 ' tvwRootLines  commented out as with rootlines does not work

       TreeView1.Style =  2 ' 7 - tvwTreelinesPlusMinusText ' works with Style 1 or 2

     

     

     

    Regards

    AA



  • 8.  Re: Change Background of Treeview

    Posted Mar 21, 2016 09:12 AM

    and here lies the issue a treeview kinda needs the ability to collapse and expand in most cases. I could find no way so far of getting the 'yellow' colour in the background of the plus signs.

     

    Capture.PNG

    Dim I 
    For I = 1 to TreeView1.Nodes.Count
    TreeView1.Nodes(I).BackColor = RGB(255, 255, 0)
    Next
    


  • 9.  Re: Change Background of Treeview

    Posted Mar 21, 2016 09:45 AM

    Works with no rootlines and with Style  0 , 1 and 2. With other styles leaves blocks of old background on the left , in some cases with the last expandable node.

     

     

    With Node level text formating ability(Bold & Text color ....may be more ) , i think ver 6 is still a good choice.

     



  • 10.  Re: Change Background of Treeview

    Posted Mar 24, 2016 06:39 AM

    Hi Ashfaq

    Thanks a lot for your help.

    Where can I find more information how to change color, font or fontsize of a node when loading a tree or for a selected node?

    I searched the net but I didn't find examples that worked in Plex.



  • 11.  Re: Change Background of Treeview

    Posted Mar 24, 2016 12:03 PM

    Hi Markus,

     

    While loading modify Add parent / Add Child Script.

    Text Color & Bold/Regular could be changed easily.

    Font size takes effect for the entire treeview using (TreeView1.Font.Size = n).

     

    Selected node highlight behaviour is overridden by the system color setting for Selected Item.

     

    Add Parent script modified.

     

    Or at the end

     

    Regards

    AA



  • 12.  Re: Change Background of Treeview

    Posted Mar 21, 2016 11:41 AM

    Node.Bold is a property supported in ver 6 and not in ver 5.