Solved

How make a TreeView in run-time...

Posted on 1998-10-22
6
165 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

14 Experts available now in Live!

Get 1:1 Help Now