Foxhound is the better* Database Monitor for SQL Anywhere.
*better: More thorough, more relevant, more effective.
...more Alerts, more All Clears, more details, more control in your hands.


[Home] [Back to Tip 70] [Forward to Tip 72] [Archives]

Breck Carter
Last modified: February 18, 1998
mail to: bcarter@bcarter.com



Tip 71: ScrollToFirstRowOnPage

How do I get the row highlighting to move as I use the vertical scrollbar? I have a freeform DataWindow that shows one row at a time.

Figure 1 shows what we really want: The user has put the cursor on Product Name and then used the vertical scroll bar to move to another row in the DataWindow. The cursor remains on Product Name, however, this time on the new row.

Figure 1: Moving the Current Row


One solution is shown in Figure 2. Whenever the vertical scrollbar is used the ScrollVertical event is fired. The script calls Describe() to get the row number of the first (and only) row displayed on the new page. It then calls ScrollToRow() to force that row to be the current row, thus causing the column highlighting to move as well.

Warning! ScrollVertical scripts are very dangerous. In particular, response windows should not be displayed from a ScrollVertical event. This means that MessageBox() should not be called, and DataWindow error messages should not be produced. In other words, this Tip should only be used for display-only DataWindows.

Figure 2: DataWindow ScrollVertical Event
integer li_RC
long    ll_row
string  ls_result

// Get the row number at the top of the current page...

ls_result = this.describe ( "DataWindow.FirstRowOnPage" )
if ls_result = "!" then
   return // error
end if

ll_row = long ( ls_result )

if ll_row < 1 then
   return // error
end if

// ...and call ScrollToRow to make it the current row.

li_RC = this.ScrollToRow ( ll_row )
if li_RC <> 1 then
   return // error
end if

The SetRow() function would probably have worked just as well as ScrollToRow() in this case. What we really need, of course, is a "Always Scroll To First Row On Page" checkbox in the DataWindow painter.


[Home] [Back to Tip 70] [Forward to Tip 72] [Archives]
     
[mail to: bcarter@bcarter.com]