Link to home
Start Free TrialLog in
Avatar of jonjon
jonjon

asked on

Multiple Text colors in TreeView Control for different Nodes

Using VB6, trying to use more than one text color on the
treeview nodes.  Node one is Blue, Node two is Red for
example.  I know that this can be done using c++, and that
the VB Treeview is a wrapper around the c++ version.  I
can get a handle to the TreeView.Node(TV_ITEM) and I
attempt to SendMessage a message via:
"Call SendMessage(hItem, TVM_SETTEXTCOLOR, 0, ByVal
clrref)"
Anybody know if more than one text/fore color can be used in the same treeview?
Thanks
.
Avatar of mdougan
mdougan
Flag of United States of America image

Don't know about the treeview that ships with VB.  But, if it turns out that you can't do it with the standard treeview, it is possible to do this using the VSFlexGrid Pro v7.0 from ComponentOne (formerly VideoSoft).  It's a grid control, but has a mode where it can perfectly simulate a treeview, only it gives you total control over each cell (node).  You can have different fonts, different foreground or background colors, whatever you want.  And, in my opinion, it works better than the Treeview for a lot of different things.
    tv1.Nodes(1).Forecolor = vbRed
Avatar of jonjon
jonjon

ASKER

ameba,
   'Forecolor' is not a member of the Nodes collection, your suggestion produces an error.  Any other ideas?
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonjon

ASKER

ameba,
   You hit it on the head.  This is an old VB project that I inherited that had two versions of the "Microsoft Windows Common Control" loaded. (5.0 and 6.0)  This particular TreeView control was a version 5.0.  I got rid of the version 5.0 and replaced it with a Treeview version 6.0 and the .ForeColor appeared.  I was able to change the color for each node as I needed.

Thanks,
Wow, thanks for extra points!  :-)