Remove fields created at run time

0

I have the following function to clean the common edits :

for I := 0 to componentCount-1 do
  begin
  If(components [i] is Tedit) then
  Tedit(components[i]).Text := '';
  end;

But I have edits created at runtime, and would like them to "disappear" when the person clicks the clean button. How can I include this in my role?

    
asked by anonymous 01.10.2015 / 16:13

2 answers

1

If they "disappear" is not to present them, just do a similar routine by replacing the line

Tedit(components[i]).Text := '';

for

Tedit(components[i]).Visible := False;

However, if they "disappear" to destroy replace with

Tedit(components[i]).Destroy;

Attention. When using Destroy keep in mind that the object has been destroyed, then all future references to these objects will cause an access violation. Protections should be made for this case.

    
01.10.2015 / 22:32
1

Never use Tedit (components [i]). Destroy directly in place Tedit (components [i]) Free that internally does the memory release treatment and call the correct events.!

    
20.10.2015 / 22:39