1
When creating a Tbutton dynamically at runtime within a Tvertscrollbox. When I need to delete this button it does not disappear from the screen. This problem only occurs by running the application on Android (on Windows works properly).
To delete the buttons created at runtime within Tvertscrollbox I run this routine:
for i := vsScroll.ComponentCount-1 downto 0 do
if vsScroll.Components[i] is TButton then
TButton(vsScroll.Components[i]).Free;
How do I remove created components?
Note: No use to use TButton(vsScroll.Components[i]).Destroy
instead of Free
.
This way I believe that before the end of the "loop" will generate an error, as the component count has already been decreased with each removal.
– Carlos Andrade
It wouldn’t be viable just to make the object invisible instead of eliminating it?
TButton(vsScroll.Components[i]).Visible := false;
– Carlos Andrade
@Carlosandrade, no error at the end of the loop (the normal way yes, will give error... can try). About making the component invisible, is not feasible. They have to be eliminated. After all the function
Free
has this goal and as a consequence, by eliminating the object, it becomes invisible.– wBB