Are the event order fixed in a ContainerControl?

I want to create a custom control in a ContainerControl, it will have many properties, and depending on this values, it will change the sizes and contents of internal controls. All this changes take place in a Update method, and when the properties change, they call this method. So, when the control is being created, and the properties initialized, Update is called lots of times.

To avoid this I create a new Is IsLoading = True property, and in update add as first line, If IsLoading = True Then Return, then At the end of the Open Event of the ContainerControl IsLoading = False and call the update, but, this is called twice, then I realize that there is an extra resized event in there.

So, the event order when the ContainerControl is created is: Resized, Open, Resized

Unfortunaly, there is nothing on the documentation about a event order, so:

  1. Why Resized is raised twice when the ContainerControl is created?

  2. Is this order reliable to set IsLoading = False on the open event and deppend on the second Resized event to call the update method?

In an event driven environment, you should never rely on events order. If necessary, program defensively and test whether data is available. A simple flag as you did for isLoading can usually prevent collisions.

One of the two resized events seems superfluous
Theres one before the open event of the container -and that seems odd to get that as I believe this is the container control instance being created and its size being set initially
And then you get one after the open event when its size should be changing as far as I can tell
And all of this is BEFORE the Windows open event has run

I’d file a bug report about this JUST to be safe

All you need is quick projects with an a container control with the events Open and resized implemented with “BREAK”
put an instance on a window and in the windows open event also put “BREAK”
and run
and see where you land and when

here I see
ContainerControlInstance.Resized
ContainerControlInstance.Open
ContainerControlInstance.Resized
Window.Open

That said Michel is correct and you should not rely on event order

<https://xojo.com/issue/55578>

I think the same

I did that but without the window events, doing so, here I see:

ContainerControlInstance.Resized
ContainerControlInstance.Open
ContainerControlInstance.Resized
Window.Open
Window.Resized

Yes, I better play safe, even if I had an extra call to the update method.

Thanks