Synchronizing Scrolling on Shared Datawindows in PowerBuilder

This sample assumes you have two visible datawindows of type free-form showing one row at a time and you want to keep then in sync at all times.  The only time you’d probably do something like this is if you want to split up columns for a row or possibly splitting columns by table (assuming join) and later manipulating the update statement so that multiple tables are updated.

The primary datawindow has a scrollbar and the secondary does not.  The sample code assumes that navigation will be done from the primary, if the user may navigate from the second datawindow then the script could be added to it as well.

1. In the open event of the window, in addition to any connection and/or retrieval code add a ShareData function call.


2. Add a new user event “ue_scrollvertical” to the primary datawindow object control (dw_primary) to handle sync to the secondary.  Add the following code to it.

long ll_row
string  ls_row

// Get the FirstRowOnPage on the primary datawindow (freeform) and scroll to same (freeform) on secondary
ls_row = this.Object.DataWindow.FirstRowOnPage

if IsNumber(ls_row) then
    ll_row = Integer(ls_row)
end if

Add code to the ScrollVertical event of the primary datawindow control object (dw_primary) to call the new event created.

this.event post ue_scrollvertical()


This example assumes the primary datawindow object has focus and navigation is applied to it.  The same code may need to be added to the secondary datawindow if navigation from it is possible.


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *