Defining .NET Properties

.NET properties get or set a specific data value of an object, and allow you to process that value while enabling the actual member instance to remain private.

You can define .NET properties in application objects, windows, menus, and standard and custom user objects. PowerBuilder .NET object painters provide an easy way to script "getters" and "setters" for .NET properties.

  1. Open the painter for the object in which you want to define .NET properties.
  2. From the drop-down list at the upper left of the painter, select Properties.
    A property signature or prototype area appears between the main item selection area and the scripting pane.
  3. In the main item selection area, make sure New Property appears in the second drop-down list.
    Before a .NET property is defined for the current object, New Property is the default selection. If .NET properties are already defined, the default selection is the most recent .NET property viewed for the current object.
  4. In the drop-down list at the right of the prototype area, select:
    • get – to add a getter method.
    • set – to add a setter method.
  5. In the drop-down list at the left of the prototype area, select the access scope for the .NET property.
    Available selections are public (default), protected, and private.
  6. In the second drop-down list of the prototype area, select the return type for the .NET property.
  7. In the third drop-down list of the prototype area, enter a name for the .NET property.
  8. In the scripting pane, enter the processing code for the .NET property getter or setter method.
    If you do no other processing with the values that you get or set, you typically:
    • For getters – enter return followed by a variable of the selected return type.
    • For setters – set the property or a variable to the context keyword value.
  9. To script:
    • The other accessor type (getter or setter) for the current .NET property, repeat this procedure from step 4, making the other accessor type selection from the one you previously made.
    • A new .NET property for the current object, repeat this procedure from step 3.
  10. Save the object.