In PowerBuilder .NET, you can define parameterized constructor events that overload the default constructor event, and instantiate the object with the arguments that you assign in the overriding event prototypes.
Parameterized constructor events are supported on all custom and standard class nonvisual user objects.
If no arguments are passed in the call to instantiate a user object, the object's default constructor event is triggered instead of the parameterized constructor.
To create and invoke a parameterized constructor:
- Open the object painter for an object that supports parameterized constructor events.
To create a new object with a parameterized constructor, double-click the object type in the New dialog box and follow the same steps as for an existing object.
- Make sure the object name or Untitled appears in the first drop-down list in the object prototype area, and select New Constructor from the second drop-down list.
- Define an overloaded constructor event with the arguments you want to include.
Add at least one argument to each new constructor event.
- Create an object by passing in values for the arguments in the overloaded constructor event.
This example creates an object with two arguments:
Obj obj = CREATE obj(1, 2)