Support .NET Events

You can invoke .NET events from PowerScript code.

Since .NET events are a kind of delegate variable, you can use delegates to consume .NET events in PowerScript, as long as the delegate has the same signature as the .NET event. You can connect single or multiple methods to a .NET event in Powerscript. The method can be a PowerBuilder global function, an instance function of a PowerBuilder object, or an instance or static function of a .NET object.

When you consume a .NET event, you do not declare it in PowerBuilder code, because it is not a type. Instead, declare a variable or parameter and assign it a .NET event, using the Powerbuilder += operator.

Dynamically Connecting to a .NET Event in PowerScript

// Define a PowerBuilder event that has the same signature as the.NET Clicked event
// (defined in the .NET system.windows.controls.button control). 
Event  OnClick1(system.object sender, RouteEventArgs e)

// Connect the PowerBuilder event to the .NET Clicked event.
System.Windows.Controls.Button cb1
Cb1  = create System.Windows.Controls.Button()
Cb1.clicked += onClick1