Solved

Displaying what I want in a treeview node.

Posted on 2003-12-08
6
254 Views
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
0
Comment
Question by:PPaul
  • 2
  • 2
6 Comments
 
LVL 9

Accepted Solution

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

implementation

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

procedure TForm1.FormCreate(Sender: TObject);
var
  nd: TTreeNode;
begin
  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');
end;

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

wbr, mo.
0
 

Author Comment

by:PPaul
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?

Thanks

 
0
 
LVL 9

Expert Comment

by:mocarts
ID: 9907015
try this solution (also possible to save virtually all other properties of TTreeNode):
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20558338.html

wbr, mo.
0
 

Author Comment

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

Thanks
PPaul
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now