Solved

How make a TreeView in run-time...

Posted on 1998-10-22
6
166 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 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.

 
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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

21 Experts available now in Live!

Get 1:1 Help Now