Try OpenEdge Now
skip to main content
GUI for .NET Programming
Accessing and Managing .NET Classes from ABL : Handling .NET events : Defining handlers for .NET events in ABL : Identifying the signature for an event handler on a third-party .NET object
 
Identifying the signature for an event handler on a third-party .NET object
As described in the previous section, you can identify the signature required for an event handler from the .NET documentation for the event.
To identify the signature required for any ABL method or procedure that you want to define as a handler for a .NET event on a third-party .NET object, such as a Microsoft or an Infragistics object:
1. In either the .NET Class Library or the API Reference documentation (see OpenEdgeInstalled .NET Controls), look up the object event that you want to handle—for example, the FormClosing event of System.Windows.Forms.Form. The documentation shows the event declaration using the syntax of several .NET languages. In C#, the FormClosing event declaration appears as follows:
public event FormClosingEventHandler FormClosing
2. The word (following event) that typically appears as a hypertext link in this event declaration is the name of the delegate class associated with the event. Click on this link. The documentation for the associated delegate class appears—in this case, it is for the System.Windows.Forms.FormClosingEventHandler delegate. The documentation shows the event handler prototype using the syntax of several .NET languages. In C#, the FormClosingEventHandler prototype appears as follows:
public delegate void FormClosingEventHandler
  (Object sender, FormClosingEventArgs e)
3. This signature indicates the return type (void by convention) and the parameters that you must define for your event handler—in this case, the typical first parameter, which is a System.Object, and the second parameter that for the FormClosingEventHandler delegate is a System.Windows.Forms.FormClosingEventArgs class. In this case, you might use the Cancel property of the FormClosingEventArgs class to cancel the FormClosing event, which prevents the form from being closed.
Note: For any ABL method or internal procedure defined as a .NET event handler, if you never intend to actually use the second parameter of its signature, or you prefer to cast the object reference to its specified event arguments subclass at some later point in the event handler block, you can always define this parameter using the common event arguments base class, System.EventArgs.