Solved

Drawing a tree in delphi?

Posted on 1998-06-29
3
897 Views
Last Modified: 2012-06-27
I need to draw a tree using delphi, I guess the best component available is Toutline??

Anyhow, I can draw nodes on this tree easily using
Outline1.Insert(0,'a node');

But I can't seem to figure out how to draw a children for that node...

ie how do i draw this (help me with the missing code)

-a node
-another node
 -child of another node
  -child of the child

Outline1.Insert(0,'a node');
Outline1.Insert(1,'another node');
???
???

Also, how can I remove nodes/children..

This is probably a very easy question... so thanks for taking the time to answer it...

By the way, if there is another component that may be better suited for drawing trees (I need a tree of text not files) please let me know...

0
Comment
Question by:rafyt
3 Comments
 
LVL 2

Accepted Solution

by:
kjteng earned 50 total points
ID: 1356554
Each item in the outline tree has a reference number, you must refer to these number when you want to add child to a specific node or when you want to delete an item.

You can get the index number for a selected item from the outline.selectedItem property

Please read the delphi help for more details. For simple operation, I don't think you need a third party component. Yes there are some ready made components doing such things like auto drag and drop, construct tree from database info etc. Check delphiSuperPage.


Example:
procedure TForm1.BitBtn2Click(Sender: TObject);
var i: longint;
begin
  with outline1 do begin
{  -a node}
   add( 0, 'a node');
{  -another node}
   i:= add( 1, 'another node');
{    -child of another node}
   i:= addChild( i, 'child of another node');
{    -child of another node}
   i:= addChild( i, 'child of child');
   fullExpand
 end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
{ remove nodes/children}
  with outline1 do
    delete( selectedItem);
end;
0
 
LVL 3

Expert Comment

by:vladika
ID: 1356555
Are you use Delphi 1?

0
 

Author Comment

by:rafyt
ID: 1356556
No I'm using Delphi 3... and I just found TtreeView (much better component to use!), and that's pretty well documented, so I answered my own questions...Thanks anyways
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 131
delphi parse string to params 3 152
How to renew a Delphi rad-studio licence? 5 75
creating threads in delphi 1 157
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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