Chrissy,

TWinControl's have a FindChildControl method. You can use this to
obtain a TControl referance to your TMyList control.

var
  tmpMyList: TMyList;

begin
..
  tmpMyList := Form1.FindChildControl('TreeView') as TMyList;
  tmpMyList.Visible := true;

etc..

Regards
Andrew Dibley

> -----Original Message-----
> From: Chrissy R [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 30 November 2000 11:04
> To: Multiple recipients of list delphi
> Subject: [DUG]: Creating An Object At Run Time
> 
> 
> Hi,
> 
> Thanks for you help yesterday on creating an object 
> (TreeView) but I am
> still having problems.  I can create as many objects as I 
> want but I do not
> know how to access these in code at a later stage.  I want to 
> be able to 
> insert, delete etc nodes, make the TreeView invisible and 
> lots of other things
> but I do not know what it is called so I cannot use, for example, 
> 
> xxx.Visible := False;
> 
> I do not know what to use in place of "xxx".  The code is as 
> follows and there
> is one form with a button and two units - all with default names.
> 
> 
> Chrissy.
> 
> 
> unit Unit1;
> 
> interface
> 
> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, 
> Forms, Dialogs,
>   ComCtrls, StdCtrls, unit2;
> 
> type
>   TForm1 = class(TForm)
>     Button1: TButton;
>     procedure Button1Click(Sender: TObject);
>   end;
> 
> var
>   Form1: TForm1;
> 
> implementation
> 
> {$R *.DFM}
> 
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   MyList1: TMyList;
> begin
>   MyList1 := TMyList.Create(Self);
>   MyList1.Parent := Form1;
>   MyList1.Items.AddChildFirst(nil,MyList1.Name);
>   MyList1.Name := 'TreeView';
>   MyList1.Visible := True;
>   MyList1.Items.AddChildFirst(nil,MyList1.Name);
>   MyList1.SendToBack;
> end;
> 
> end.
> 
> 
> unit Unit2;
> 
> interface
> 
> uses
>   ComCtrls, Controls, Classes;
> 
> type
>   TMyList = class(TCustomTreeView)
>   public
>     constructor Create(AOwner: TComponent);
>   published
>     property Items;
>   end;
> 
> implementation
> 
> constructor TMyList.Create(AOwner: TComponent);
> begin
>   inherited Create(Owner);  // Initialize inherited parts
>   Align := alLeft;
> end;
> 
> end.
> 
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to