Remove fields created at runtime

Asked

Viewed 864 times

0

I have the following function to clear edits common:

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

but I do own edits created at runtime, and would like them to "disappear" when the person clicks the wipe button.
How can I include in my role?

2 answers

1


If "disappear" is not presenting them, just make a similar routine by replacing the line

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

for

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

However, if "disappear" is to destroy replace by

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 must be made for this case.

  • I’d like them to cease to exist, and then when someone requests them to reappear, I’ll test Dysstruy.

1

Never use Tedit(Components[i]). Destroy directly in place Tedit(Components[i]). Free who internally makes the memory release treatment and call the right events.!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.