Solved

Drawing a tree in delphi?

Posted on 1998-06-29
3
903 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 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