Changing the DataWindow in PowerBuilder

When you associate a DataWindow object with a control in the window, you are setting the initial value of the DataWindow control’s DataObject property.

During execution, this tells your application to create an instance of the DataWindow object specified in the control’s DataObject property and use it in the control.

Setting the DataObject property in code

In addition to specifying the DataWindow object in the Window painter, you can switch the object that displays in the control during execution by changing the value of the DataObject property in code.

For example: to display the DataWindow object d_emp_hist from the library emp.pbl in the DataWindow control dw_emp, you can code:

dw_emp.DataObject = "d_emp_hist"

The DataWindow object d_emp_hist was created in the DataWindow painter and stored in a library on the application search path. The control dw_emp is contained in the window and is saved as part of the window definition.

NotePreventing redrawing You can use the SetRedraw method to turn off redrawing in order to avoid flicker and reduce redrawing time when you are making several changes to the properties of an object or control. Dynamically changing the DataWindow object at execution time implicitly turns redrawing on. To turn redrawing off again, call the SetRedraw method every time you change the DataWindow object:

dw_emp.DataObject = "d_emp_hist"
dw_emp.SetRedraw(FALSE)

Using PSR files

To put a PSR file into a DataWindow control at execution time, change the control’s DataObject property to specify that PSR file name.