Clear a canvas

I have several object, which are container controls, placed on a canvas.
What’s the best method to clear the canvas, so no object is displayed any more.

Either Hide the containers or Close them if they’re no longer needed.

is that all can do ? than a canvas is not much use for me …

thank’s Tim

If the canvas is the parent of the containers, you can simply hide the canvas, which will hide all the containers, too.

What do you want to achieve ?

I want to remove all container objects from canvas and display new container objects.

A decade ago, we solved this by placing a Self.Close Method inside the Container itself and calling this Method via a Timer that is inside the Container.

I can’t remember why we couldn’t close the Container externally, but it had to close itself to be removed.

This solution might be well out of date.

yes, there is a canvas.close method which removes the canvas, which I don’t want, I need the canvas to place different objects on.

Instead of using a canvas, use a DesktopContainer, so with ControlCount you can iterate through all containers and remove each.

I may be wrong, but what about:

Graphics.ClearRectangle ?

that sounds good Michael, I’ll try that, thanks

can you make that container scrollable ?

You can put your canvas within the container.

it works perfect with a container control.
All added controller controls I remove with cc.close
Thanks for sending me the right way !

1 Like