[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

How make a TreeView in run-time...

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
Garneau
Asked:
Garneau
  • 3
  • 3
1 Solution
 
GarneauAuthor Commented:
Edited text of question
0
 
ZifNabCommented:
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
 
GarneauAuthor Commented:
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!

 
ZifNabCommented:
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
 
GarneauAuthor Commented:
>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
 
ZifNabCommented:
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

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!

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