Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Treeview and text files

Can i populate a treeview, with each node being the contents of a text file???  This would have to be about 5/6 lines for each node.

or is there a method to populate treeview, and show the data for each node in the text box next to it.

for example, clicking on node A loads a text file into the text box relating to contents A?
0
rangi999
Asked:
rangi999
  • 3
1 Solution
 
kretzschmarCommented:
Procedure LoadToNode(ANode : TTreeNode);
var Node : TTreeNode;
    sl : TSringList;
    i  : integer;
begin
  if assigned(ANode) then
  begin
    sl := TSringList.Create;
    try
      sl.LoadFromFile(ANode.Text+'.txt');
      for i := 0 ro sl.count-1 do
        ANode.TreeView.Items.Addchild(sl[i]);
    finally
      sl.Free;
    end;
  end;
end;

just from head

meikl ;-)
0
 
kretzschmarCommented:
ro -> to :-))
0
 
kretzschmarCommented:
terrible typo
this

     for i := 0 ro sl.count-1 do
       ANode.TreeView.Items.Addchild(sl[i]);
     
should be

     for i := 0 ro sl.count-1 do
     begin
       Node.TreeView.Items.Addchild(ANode);
       Node.Text := sl[i];
     end;

meikl ;-)
0
 
CleanupPingCommented:
rangi999:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept kretzschmar's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now