Subscribing to an event in a ABL User control

Posted by Peter Baaijens on 22-Nov-2010 02:27

Hi community,

I'm trying to subscribe to an event from a ABL user control event, but having troubles to do this.

What I did:

Created a ABL user control and put an Ultragrid in it.

This all works fine, all suppliers are shows.

In another class, OverviewSupplier, I included this user-control.

This must show a schedule for the selected supplier.

When a supplier is selected in the ultragrid, the schedule must be refreshed for that supplier.

In the ABL user control, with method ultraGridSupplier_AfterRowActivate a propery is set (iSelectedSupplier)

and an user-defined event is published.

THIS-OBJECT:SupplierSelected:PUBLISH(sender, e).

The event is defined like

DEFINE PUBLIC EVENT SupplierSelected SIGNATURE VOID (sender AS System.Object, e AS System.EventArgs).

From my OverviewSupplier class I tried to subscribe to this event, but this where I'm having troubles.
Within the contructor I tried to define
but this is not accepted by the compiler.
Where did I go wrong?!
Thanks in advance

All Replies

Posted by Peter Judge on 22-Nov-2010 07:30

Do you have a method called "suppliers1_SupplierSelected" in the OverviewSupplier class (with the right signature)?

-- peter

Posted by whenshaw on 22-Nov-2010 07:55

What is the error message from the compiler?

Posted by Peter Baaijens on 22-Nov-2010 08:02

The error was

No accessible overload of suppliers1_SupplierSelected in class OverviewSupplier

has the signature required for the SupplierSelected event.

After changing the type of the e parameter into System.EventArgs the event subscription works!


Posted by jmls on 31-Oct-2012 03:20

if you are using the AVM garbage collecter (ie not explicty deleting every object you create and leaving it to the avm) be _very_ careful of subscribing to events , as there is a reference to the subscriber so GC will never clean up the object even when it goes out of scope.

for example

./** class foo*/


bar1 = new bar().


/** end class foo */

now when you run this code


  foo = new foo().


foo will never be garbage collected (and hence bar1 will never be garbage collected), because bar is referencing foo due to the subscription

without the subscribe statement, both object would be gc'd . This can obviously lead to memory leaks.

the way to fix this is


  foo = new foo().


delete object foo.


because you are explicitly deleting the object, both foo and bar1 are removed.

Posted by jquerijero on 13-Nov-2012 13:07

Do you mean if the bar goes out of scope bar will not be collected? Or do you mean if foo goes out of scope foo will not be collected? If it is the later then it doesn't sound right. If I rememeber it correctly in .NET programming a child object (bar) having a lingering reference to the parent should never stop the parent object (foo) from getting collected when the parent object goes out of scope.

If this is a case then design-time controls/components will prevent the form from being collected. We actually have an open case where Form closed using the red X or THIS-OBJECT:Close(), and has UltraToolbarsManager or UltraDockManager will not get collected.

This thread is closed