How do I access action event of a control within a container

Create a container with a list box. Then place three instances of the container on a window.
In the navigator, you will have Container 11, Container12, and Container13. How do I program the events for each list box in each container?

Right-mouse each one in the Navigator and choose Add event.

If you need the same action for each of the inserted containers, all you have to do is to add the event code in the original container. Then when you fire the event, it will work in the context of the specific instance.

I would like to use each instance of the Listbox container separately. I am having a problem with how to access the events of the Listbox that is embedded in the container, as no two listboxes will have the same action

You will have to dispatch the events of the listbox to events you add to the container.

Within the container definition:
Add the event to the listbox. (Add → Event Handler)
Add code to call a private method on the container.
Have that method RaiseEvent an event you add to the container. (Add → Event Definition)

Now when you place the container on your window, you can add the container’s event in the navigator panel and put your listbox-specific code in it.

1 Like