DWObject arguments for DataWindow events in PowerBuilder

In PowerBuilder, several DataWindow events pass a DWObject argument called dwo to the event script. The value is a resolved reference to a control within the DataWindow having something to do with the user’s action that triggered the event. Often it is the column the user is changing or the control the user clicked.

What type of DWObject?

You can use DataWindow properties to find out more about the control stored in dwo. The first step is to find out the control’s type so that subsequent statements will use properties that are appropriate for the control type. If an expression uses a property that does not correspond to the control’s type, it will trigger the Error event. This statement in an event script gets the type:

ls_type = dwo.Type

The possible values that can be assigned to ls_type are:

You can write a CHOOSE CASE statement for the expected types.

After you have determined the type, you can get more details about the specific control.

Examples

If the control is a column, you can get the column name with this statement:

ls_name = dwo.Name

If the control is a column, you can get data from the whole column or from specific rows. You must specify the buffer from which you want to retrieve data. In this statement, row is another argument passed to the event so the value in ls_data is the data in the row and column the user clicked. In this example, if the column value is not a string, an error occurs (check ColType property to get the column datatype):

ls_data = dwo.Primary[row]

This statement assigns a new value to the row and column the user clicked. The assignment does not trigger the ItemChanged event and bypasses validation. If the column is not numeric, an error occurs:

dwo.Primary[row] = 41

This statement gets all the data in the column the user clicked. The data is stored as an array in the Any variable. An Any variable can hold all datatypes, so no error occurs:

Any la_data

la_data = dwo

This statement gets data in the column from selected rows. The data is stored as an array in the Any variable:

Any la_data

la_data = dwo.Selected