Description
PowerBuilder.RegisteredObject.TriggerEvent is a .NET method, not a PowerScript method.
It is called in the C# code to trigger the event of the PowerBuilder object. For details, refer to Triggering PowerScript events from C# code in Application Techniques.
Dynamic library
The following runtime DLL files must be referenced in the C# code according to the target framework:
-
pbdotnetframeworkinvoker.dll for .NET framework (when the .NET assembly is loaded through LoadWithDotNetFramework)
-
pbdotnetcoreinvoker.dll for .NET core (when the .NET assembly is loaded through LoadWithDotNetCore)
-
pbdotnetinvoker.dll for .NET (when the .NET assembly is loaded through LoadWithDotNet)
These runtime DLL files are located in the PowerBuilder Runtime directory (by default %systemdrive%\Program Files (x86)\Appeon\Common\PowerBuilder\Runtime [version]) and will be deployed automatically.
Namespace
PowerBuilder
Syntax
int RegisteredObject.TriggerEvent(string registeredObject, string eventName{,string eventParam}{,ref string returnValue})
Argument |
Description |
---|---|
registeredObject |
The registered name of PowerBuilder object that is case-sensitive. |
eventName |
The event name to be triggered. |
eventParam (optional) |
The parameter of the event. |
returnValue (optional) |
The return value of the event. |
Return value
Integer.
Returns values as follows.
1 -- Success
-1 -- Unknown error.
-50 -- PowerObject is not instantiated.
-52 -- The objectname is not registered.
-53 -- Invalid event name.
-54 -- The number of event parameters is wrong.
-55 -- Event parameter type error.
Examples
This C# code triggers the ue_ondotnetcallback event of the PowerBuilder object w_dotnettest:
// Need to add the corresponding pbdotnetcoreinvoker.dll or pbdotnetframeworkinvoker.dll or pbdotnetinvoker.dll to the project reference namespace Appeon.PowerBuilder.DotNet.Test // These dll files are located in the PB Runtime directory and will be deployed automatically { public class TriggerPBEvent { public string Method(string str1) { string strResult = ""; PowerBuilder.RegisteredObject.TriggerEvent("w_dotnettest","ue_ondotnetcallback", "Param from Method", ref strResult);// Trigger the ue_ondotnetcallback event in the PB object w_dotnettest return str1 + "(Method)\nReturn:" + strResult; } } }
This PowerScript code defines the user event ue_ondotnetcallback and calls the callback function to get the result of executing user event in C# code:
// w_dotnettest window event ue_ondotnetcallback string ls_test ls_test= "ue_ondotnetcallback(as_param:" + as_param +")" return ls_test // Call the method Method in DotNet ls_return = lcs_ass.Method("PB event callback test") MessageBox("Info", ls_return)