Event Definition AddHander

I’m having an issue getting a Event Definition to on a WebContainer when adding them at Run Time.

If I add an Event Definition called TestDef to a WebContainer and then drag that Container onto a WebPage and do right click Add Event Handler my TestDef Event Definition is available and works fine.

If however I want to add the WebContainer to the WebPage as run time AddHandler doesn’t show the Event Definition TestDef.

Am I missing something?

Can you show us your code?

Greg, It’s nothing special just made up a simple test project

   ContainerControlX = New ContainerControl1
  
  ContainerControlX.EmbedWithin WebPage1, 300, 0, ContainerControlX.Width, ContainerControlX.Height
  
  '  CAN'T DO THIS TESTDEF is missing
  'AddHandler ContainerControlX

Very simple example

https://dl.dropboxusercontent.com/u/76235150/Xojo/Test.xojo_binary_project

Testdef is not missing, it just doesn’t autocomplete, you have to type it fully. The same thing happens when you subclass a timer and user addhandler to handle the action event.

Thanks Wayne I new it would be something silly I was doing, need some sleep it’s 2am!

I wouldn’t call it silly. Xojo’s autocomplete is pretty awesome, so when it doesn’t work as we expect we feel a little lost :slight_smile: Even worse at 2am.

Hi,
I am encountering the same problem without being able to resolve it.
I have the event definition ed_followup in my Container_LabelSpec

Dim cb As WebContainer = New Container_LabelSpec cb.EmbedWithin(Container_SpecList1,0,p_ytop4,480,35) AddHandler cb.ed_followup, AddressOf Page_appointment.m_SpecSelect

What am I missing?

Don’t Dim your webContainer. It will cease to exist at the end of the event.

Add it as a property to the WebPage, so it stays around.

cb As  Container_LabelSpec

cb = New Container_LabelSpec cb.EmbedWithin(Container_SpecList1,0,p_ytop4,480,35) AddHandler cb.ed_followup, AddressOf Page_appointment.m_SpecSelect

Of course, the event ed_followup must have been defined in Container_LabelSpec.

Usually, I keep the same name for the method as the class where the event has been defined.

For instance Container_LabelSpec_ed_followup

Merci Michel,

I set the property to the WebPage;

Public Property cb as Container_LabelSpec
I set the event definition in Container_LabelSpec;

Event ed_followup()
The runtime code:

cb = New Container_LabelSpec cb.EmbedWithin(Container_SpecList1,0,p_ytop4,480,35) AddHandler cb.ed_followup, AddressOf Page_appointment.m_SymptomSelect
and I got this Error message:

[quote] Type mismatch error. Expected delegate Delegate( Container_LabelSpec.Container_LabelSpec ), but got delegate Delegate( )
AddHandler cb.ed_followup, AddressOf Page_appointment.m_SymptomSelect
[/quote]