Container Events - Redux

Ok… I know there has to be a way to do this.
a) I have a container control, that contains a canvas
b) one of the properties of the CC is a custom class (not subclassed from a control), Call it “X”
c) What I need to be able to do. If a particular method in “X” does a particular action, I need it to raise an event that the “CC” can see and respond to (ie. invalidate the canvas

I have added an event defintion to “X”, but there is not Event Handler exposed in “CC”… what am I missing

CC.doSomething  // if this DID do something I need CC to react, without putting code in the main app

I do not wish to do something like this

If CC.doSomething then CC.Invalidate

Raise the event in the X class then receive it in the container using AddHandler. Make sure you do a remove handler when the container is closed.

Add the handler in code
Or drag an instance on to the CC in the layout editor

Ok… This is not working

CC has property of class “X”
Class “X” has an event definition “Z”

In the Constructor of CC I have

obj=new X
AddHandler obj.z, addressof me.handle_event_z

and in CC there is a method called “handle_event_z”

Error on AddHandler line is
Type Mismatch error. Expected delegate Delegate(X), but got delegate Delegate ( )

Add a parameter to me.handle_event_z of “sender as X”.

That seems to be the trick :slight_smile: