Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Displaying what I want in a treeview node.

Posted on 2003-12-08
Medium Priority
Last Modified: 2010-04-05
I want to control what text is being painted in a TreeView component. This is so I can add a rem like statment to the end of each node's text area, but I don't want this rem statment to be displayed. I'm Updating my component "PathTreeView" to do this.

I know that I can use the "OnCustomDrawItem" but the example that comes with D5 shows that I would have to handle the complet drawing of the node when I only just want to handle the text display. Is there a way to get around this and let the default drawing of the indents, lines, images and buttons be handled default and only edit the text display when it get's to it?

Giving the points for a example to learn from.

Thanks PPaul
Question by:PPaul
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
  • 2
  • 2

Accepted Solution

mocarts earned 2000 total points
ID: 9903217
hi, PPaul :)
just use #0 char delimiter for Text property:


function GetHiddenNodeText(node: TTreeNode): string;
  i: integer;
  Result := node.Text;
  i := pos(#0, Result);
  if i > 0 then
    Result := Copy(Result, i+1, Length(Result)-1)
    Result := '';

procedure TForm1.FormCreate(Sender: TObject);
  nd: TTreeNode;
  nd := TreeView1.Items.Add(nil, 'some simple text'+#0+'some hidden text');
  TreeView1.Items.AddChild(nd, 'Child1'+#0+'Child1HiddenData1');
  TreeView1.Items.AddChild(nd, 'Child2'+#0+'Child2HiddenData1');
  TreeView1.Items.AddChild(nd, 'Child3'+#0+'Child3HiddenData1');

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
  Caption := GetHiddenNodeText(node);

wbr, mo.

Author Comment

ID: 9906115
That is cool... and it works.. but I found one problem with it... I'm giving you the points anyway.. The problem is that when you save the contents of the treeview to a file with SaveToFile, and then try to load it back in, it stops righ on the first #0, so the rest of the tree is not loaded in. Is there another code that can be used that will still give teh same hidden text but save to a file also?



Expert Comment

ID: 9907015
try this solution (also possible to save virtually all other properties of TTreeNode):

wbr, mo.

Author Comment

ID: 9909867
ok thanks... I'll lok at it.. you've been a big help :)


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

660 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