EVENT
|
WNSupported in Synergy .NET on Windows
|
|
|
PUBLIC event_mod EVENT event, @delegate
Arguments
event_mod
(optional) One or more of the following event modifiers:
Must have a method implemented in a derived class of the same signature. Subclasses must implement this method.
Hide an inherited member of the same name.
Overrides the parent class’s virtual method that has the same method signature.
Accessed without a reference object. The method can be executed even if the class that contains the method hasn’t been instantiated.
Can be overridden in a subclass.
event
The name of the event being declared.
delegate
A previously defined delegate to call when the event is raised. (See DELEGATE-ENDDELEGATE.)
Discussion
Events are used extensively in Windows and Web Forms. An event enables you to tie a method that handles an event to the event itself (for example, a button click). When the event occurs, the event handling methods are executed for the method.
You can register an event handler to an accessible event from an instantiated .NET class using the ADDHANDLER statement. (See ADDHANDLER.) The first parameter to ADDHANDLER must be an accessible event, and the second parameter must be one of the following:
- An accessible method whose signature matches the signature of the event delegate
- An accessible item whose type is the event’s delegate type
For example,
addhandler(var1.myevent, obj.myEventHandlingMethod) myd, @MyDelegate myd = new MyDelegate(obj.myEventHandlingMethod) addhandler(var1.myevent, myd)
The event must keep a list of all delegates to call when the event is raised. Delegates allow a function to be passed as a parameter value.
To trigger a declared event, use the RAISEEVENT statement. (See RAISEEVENT.)
To remove an event, use the REMOVEHANDLER statement. (See REMOVEHANDLER.)
Examples
See ADDHANDLER.