0
At the click of the button I create some Edits
... So far everything works normally, but when I try to exclude edits
created by clicking another button, not all are deleted.
Ex. I created 10 fields edits
, when I click to delete all at once, only 5 are deleted. Follow the codes (inclusion and exclusion respectively):
for x := 0 to (NumReg -1) do
begin
ArrayEdit[x] := TEdit.Create(Self);
ArrayEdit[x].Parent := Self;
ArrayEdit[x].Name := 'edtPreco'+ IntToStr(x+1);
ArrayEdit[x].Left := 265;
ArrayEdit[x].Top := 300 + x * 25;
end;
var Component: TComponent;
begin
for Component in Self do
if Component is TEdit then
TEdit(Component).Free;
end;
If the guy has one
TButton
in theForm1
, will already enter an infinite loop. And another question is that this way, will not destroy the lastTEdit
, for theComponentCount
will be= 1
, and not> 1
– Victor Tadashi
guy tested here fast this code and with 0 gave access Violation only with 1 worked and another if the component is Edit that will delete
– Jean Coelho
I saw that in your code you use Destroy was with a doubt about that, some time was with problem of memory Leak using free, I started to use Destroy and solved, would you explain to me the difference between the two? I searched a lot on the internet but found no answer.
– Jean Coelho