In Delphi, how to destroy a component created at runtime with a specific name?

I have a few Panels created at runtime, and thus the name is automatically assigned like PanelArray[X].Name := ‘Panel’ + IntToStr(X);
Now I need to delete a specific Panel in this array, with the name, for example Panel27.

Thanks in advance

Tags: , , , , , ,

2 Responses to “In Delphi, how to destroy a component created at runtime with a specific name?”

  1. jp_dfw says:

    How about…

    PanelArray[X].Free;
    PanelArray[X] := Nil;

  2. Niall S says:

    hi

    For i :=0 to ComponentCount -1 do
    If (Components[i] is TPanel ) Then
    If ( TPanel(Components[i]).Name=’Panel27′) Then
    TPanel(Components[i]).Free;

Trackbacks/Pingbacks


Leave a Reply

Security Code:

Categories