Solved

How make a TreeView in run-time...

Posted on 1998-10-22
6
167 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
  • 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syntax Check Delphi Seattle IOS app without MAC ? 1 97
Reconfigure Delphi Install? 2 51
Dev express lookupcombo 3 27
Delphi: sending SMS on android platform 1 21
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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