How to call a method of a container control from the window.controls() array

I’ve switched to the Registration method. I’ve a array of container controls on the parent window and a method to allow the containers to register themselves. Then you can loop through the array rather than all controls on the window.

The cost of disentangling the control from it’s EmbeddedWindowControl was enormous, especially if you take into account that every variant is an element in the runtime. It was taking 12 full seconds to find which control I had, in extreme circumstances.

Private Property Panels() as LoadSaveDataInterface

Sub RegisterPanel(CC as LoadSaveDataInterface)
  Panels.Add CC
End Sub

In each panels open event:

WindowClass( Window ).RegisterPanel( Self )

You can then do things like this in the parent window.

Public Sub PerformValidation(lblError as Label, BtnAction0 as PushButton, BtnAction1 as PushButton)
  '
  ' Trigger each panels ValidData method
  '
  For Each Panel As LoadSaveDataInterface In Panels
    Panel.SomeMothod
  Next
End Sub

By using an array of Interface (rather than class names or CustomControl) you get the protection that you can’t register an control that doesn’t support the interface and also you don’t have to perform the cast to that interface when calling it

1 Like