I got some code here, which creates a label just fine, but when I free the label it STILL shows on the form. Even though it's been removed and no longer 'assigned'.
Here is the code below. It creates the label fine, but wont remove. No exceptions, and the assigned says false.
I can reproduce this with a TRectangle as well.
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Lab : TLabel;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
Lab := TLabel.Create(Self);
Lab.Parent := Form1;
Lab.Text := 'Hello!';
Lab.Position.X := 30;
Lab.Position.Y := 40;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
FreeAndNil(Lab);
ShowMessage(BoolToStr(Assigned(Lab), true));
end;
i think
Lab.Parent:= NIL;
FreeAndNil(Lab);
could help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With