AddHandler for Many Container Controls

A window’s constructor method embeds container controls in a scrollable canvas using a For loop.

When a checkbox is clicked on any container control, a label on the window needs to be updated.

I added an event definition to the container control, and raise it in the checkbox Action event.

Is it ok to AddHandler for each container when added to the window?

If so, what’s the proper way to destroy them?

Thank you


Use Removehandler.

So I can do this?

Sub Destructor() Dim c as MyContainer For Each c in Containers RemoveHandler c.CheckBoxChange, AddressOf HandleCheckBoxChange Next End Sub

I guess I was confused on how it knows which handler do remove.

It will remove the handler for each c