Solved

How make a TreeView in run-time...

Posted on 1998-10-22
6
170 Views
Last Modified: 2010-04-06
SOMEBODY SPEAK FRENCH... ???

I'm not bilingual but i try to explain to you my easy question...

I know it's stupid but i very don't know how to make a treeview in run-time...

And after the TreeView is OK, how can include a file in a repertory of my TreeView...

For example:

Members
      Inscription

How can i do to, when i click on "inscription" i can see all of inscriptions of member (with name, phone number, city...)


     
0
Comment
Question by:Garneau
[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
  • 3
6 Comments
 

Author Comment

by:Garneau
ID: 1343933
Edited text of question
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1343934
sorry, mon français est trés terrible.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  RxNotify, StdCtrls, Buttons, ComCtrls;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Treeview1 : TTreeView;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
       var LastAddedNode, TreeNode2, ChildNode2 : TTreeNode;

       begin
        {LastAddedNode contains the last added node }
        LastAddedNode := TreeView1.Items.AddFirst(nil,'Root');
        LastAddedNode := TreeView1.Items.Add(LastAddedNode,'Root');
        TreeNode2 := LastAddedNode;
        LastAddedNode := TreeView1.Items.Add(LastAddedNode,'Root');
        LastAddedNode := TreeView1.Items.Add(LastAddedNode,'Root');
        LastAddedNode := TreeView1.Items.AddChild(LastAddedNode,'Branche1');
        LastAddedNode := TreeView1.Items.AddChild(TreeNode2,'Branche1');
        ChildNode2 := LastAddedNode;
        LastAddedNode := TreeView1.Items.Add(ChildNode2,'Brance1');
        LastAddedNode := TreeView1.Items.AddChild(ChildNode2,'Branche2');
       end;



procedure TForm1.FormCreate(Sender: TObject);
begin
 Treeview1 := TTreeview.Create(Form1);
 Treeview1.Parent := Form1;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
 Treeview1.Free;
end;

end.

       end.

for including file, use change every child into childobject (e.g. addchild -> addchildobject)

create the object, (like ttreeview in create of form)

and use addchildobject to add to tree.

when destroying!

you have to destroy the object yourself!!! don't forget this


       Hope this little example clears some things.

       Zif.

0
 

Author Comment

by:Garneau
ID: 1343935
Adjusted points to 200
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1343936
Hi Garneau, why did you increase the points?

ps. I really have to tell you this :

 when destroying!
 
 you have to destroy all the added objects yourself!!! don't forget to do this, otherwise you'll have a serious resource leak!

Zif.
0
 

Author Comment

by:Garneau
ID: 1343937
>why did you increase the points?

I do this because I did't not what to do  ? ;)

Sorry...

And i don't understand what this mean (in french):

>ps. I really have to tell you this :

> when destroying!
 
>you have to destroy all the added objects yourself!!! don't >forget to do this, otherwise you'll have a serious resource >leak!

I'm sorry i make my possible, but i'm not bilingual... :)

Sorry, mon anglais est vraiment pas très terrible... ;)


Thank's

       (My real name is Danielle...) :)

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343938
Bonsoir, Danielle,

 ok.
 When you use AddChildObject, you create memmory for the object you add with the node.
 Well, when destroying the tree, you also remove the memmory for every added object.

Example :

 MyObject := TMyObject.Create;
 AddChildObject(LastAddedNode,'NAME',MyObject);

When destroying, you need to destroy the object yourself!

e.g.

procedure TForm1.FormDestroy(Sender: TObject);
begin
 {Free here memmory of TMyObject!}
 Treeview1.Free;
end;


0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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