Board index » delphi » Deleting component

Deleting component

How to delete component of all you have is string with the Name of it ?

Greetings from Croatia

 

Re:Deleting component


Quote
>How to delete component of all you have is string with the Name of it ?

use
 function FindComponent(const AName: string): TComponent;

Re:Deleting component


On Tue, 13 Jul 1999 10:19:50 +0200, "Drago Branilovic"

Quote
<dbran...@ck.tel.hr> wrote:

>How to delete component of all you have is string with the Name of it ?

  TWinControl(FindComponent('Label1')).Free;

Un Saludo:
        Q3 Team
        www.q3.nu/trucomania

Re:Deleting component


Quote
C8591 wrote in message <19990713062126.10123.00000...@ng-ca1.aol.com>...
>>How to delete component of all you have is string with the Name of it ?

>use
> function FindComponent(const AName: string): TComponent;

Yes, something like this, in case the above is not enough detail:

procedure TForm1.NukeIt ;

var
    rComp : TComponent ;   // ref/ptr to the component you find.

begin
    // find the component, say the string is 'Button1'
    rComp := FindComponent ('Button1');

    if ( assigned (rComp) = true ) then   // we've got one!!
       begin
               rComp.Free ;     // nuke it
               rComp := nil ;     // free (in D3) does not set ptr to nil -
just to be safe!
       end ;

end ;  // NukeIt

Hope this helps.

Sincerely,

John Scalco
Software Developer
email: jsca...@bellsouth.net

Re:Deleting component


Or

FindComponent (componentName).Free;

Quote
Your Name <Patro...@glaxowellcome.com> wrote in message

news:7mfgsn$816@ussun2n.glaxo.com...
Quote

> C8591 wrote in message <19990713062126.10123.00000...@ng-ca1.aol.com>...
> >>How to delete component of all you have is string with the Name of it ?

> >use
> > function FindComponent(const AName: string): TComponent;

> Yes, something like this, in case the above is not enough detail:

> procedure TForm1.NukeIt ;

> var
>     rComp : TComponent ;   // ref/ptr to the component you find.

> begin
>     // find the component, say the string is 'Button1'
>     rComp := FindComponent ('Button1');

>     if ( assigned (rComp) = true ) then   // we've got one!!
>        begin
>                rComp.Free ;     // nuke it
>                rComp := nil ;     // free (in D3) does not set ptr to
nil -
> just to be safe!
>        end ;

> end ;  // NukeIt

> Hope this helps.

> Sincerely,

> John Scalco
> Software Developer
> email: jsca...@bellsouth.net

Other Threads