Nested raiseevent from son webContainers to father webcontainer

can a defined event (evSon) of a son webContainer (wcSon) dynamically added to a parent webContainer (WcFather) trigger a defined event (evFather) of the parent webContainer (wcFather)?

Events can only be triggered from within the class itself - if I understand what you’re describing, you’ll need to use a Method instead.

but how can I call a method of webContainerFather from a child webContainer dynamically added to the parent webContainer ?

I would like an event triggered in the child container to trigger an event in the parent container and possibly in a further parent container that contains the two previous containers

Add a “parentControl” property to your child container that hold a reference to the parent control, and set that property when the child container is embedded within the parent. Then the child will be able to call methods on the parent as needed.

1 Like

this solution cannot work if the child containers are created dynamically,
furthermore even if it could work it would be limited to two levels of encapsulation and and you need to check what type the parent container is

if I have 5 levels
contFather5 which contains ,contFather4 which contains, contFather3 which contains, contFather2 which contains contFather1 , which contains contSon

and I want that the event designated ConSon.DesignatedEvent

trigger the ContFather5.DesignatedEvent event

this solution cannot work especially if the various containers are created dynamically

I think I should use delgate or addhandler but I can’t find a good example to understand how to assign (or point) a method/event (with or without parameters) of controlA to a method/event of controlB

see AddHandler,RemoveHandler
you should get the object too with every event.

this solution cannot work especially if the various containers are created dynamically

have a look at interfaces

ok but

if i create a new event definition on cSon with name cSonNewEvent

then i dynamycally add cSon to webPage or other Contanier and i try to use addHandler, the addHnadler not show me the cSonNewEvent

addHandler cSon.cSonNewEvent is not showed

addHandler cSon… show only


but not show cSon’s Event Definitions

and if i try to use addHandler with methos like this

addHandler cSon.sonMethod, cFather.fathMethos

Dim cs As New cSon
AddHandler cs.sonMethod , CFather.fathMethod

the ide shows me this error

CFather.Shown, line 3
This method doesn’t return a value
AddHandler cs.sonMethod , CFather.fathMethod

CFather.Shown, line 3
cSon.cSon does not have an event named sonMethos
AddHandler cs.sonMethod , CFather.fathMethod

first it comes the event definition as example Action and then you can use a responsible method.
i not see the use of AddressOf in your text.

AddHandler MyTimer.Action, AddressOf TimerAction
TimerAction(sender As Timer)

in addHandler function the first parameter is eventname

AddHandler eventName, delegateMethod


addHandler cSon.cSonNewEvent is not showed

you ar right for the addressof but i must use addressof for method linked to event

Don’t rely on autocomplete for everything.


without addressOf

with addressof

You still need the addressOf part, just without the parenthesis.

AddHandler csSon.csSonNewEvent, AddressOf cFather.fathMethod

Again, don’t rely on autocomplete. It just doesn’t get this right.

Also, make sure you have a matching RemoveHandler call when you remove this container or else it’ll leak.

1 Like

Try using the instance name “cs”

1 Like

you’re right, I had the object references completely wrong,
but the problem changes and it still exists

The first parameter of the methods you pass must be of the type of the child. This enables you to have more than one on the parent at the same time and know which one raised the event. So:

FathMethod ( obj as csSon )

I really wish AddHandler could go away (or be deprecated) and require the use of delegates instead. They’re just so much easier to understand and visualize.