Solved

Multiple Text colors in TreeView Control for different Nodes

Posted on 2002-03-07
6
1,033 Views
Last Modified: 2012-08-14
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
.
0
Comment
Question by:jonjon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 6847992
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.
0
 
LVL 15

Expert Comment

by:ameba
ID: 6848474
    tv1.Nodes(1).Forecolor = vbRed
0
 

Author Comment

by:jonjon
ID: 6848521
ameba,
   'Forecolor' is not a member of the Nodes collection, your suggestion produces an error.  Any other ideas?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 15

Accepted Solution

by:
ameba earned 250 total points
ID: 6848550
Property ForeColor As OLE_COLOR
    Member of MSComctlLib.Node
    Returns/sets the foreground color used to display text for a Node object.

Maybe you are using project created in VB5 - old version of Common Controls library.
To convert project to VB6, I used to use PrjUpgd.exe
http://support.microsoft.com/default.aspx?scid=kb;NL;q194412

My version in Project, Components, is: "Microsoft Windows Common Control 6.0 (SP4)"
0
 

Author Comment

by:jonjon
ID: 6848689
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,
0
 
LVL 15

Expert Comment

by:ameba
ID: 6848719
Wow, thanks for extra points!  :-)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question