Remove controls from a scrollbox

  

I am dynamicaly (at run time) adding controls into a TScrollBox using myScrollBox.AddObject

Now I need to remove all the controls I added to put new ones.

I tryed myScrollBox.Controls.Clear but after I call that function, any control I add are not showing up.

(Warning: I’m new to delphi and Firemonkey)

Update 1

Here is how I add my objects (this is just a test function)

procedure TMainForm.TaskDetailsAdd;
var
btn1 : TButton;
intI : Integer;
count: Integer;

begin
scbTaskVariables.BeginUpdate;

count := 0;
for intI := 0 to 100 do
begin
btn1 := TButton.Create(self);
btn1.Text := ‘Salut ‘ + IntToStr(intI);
btn1.Parent := scbTaskVariables;
btn1.OnClick := Button1Click;
btn1.Tag := intI * 10;
btn1.Position.Y := intI * 50;
btn1.Position.X := intI * 15;
scbTaskVariables.AddObject(btn1);
count := scbTaskVariables.ControlsCount;
end;
scbTaskVariables.EndUpdate;
end;

The funny thing is that if I place a break point on count := scbTaskVariables.ControlsCount
I can see that ControlsCount goes from 0 to 1 for the first control and then it stays to 1 for the others.

Update 2

I submitted QC#125440.

Comments are closed.