Please enable JavaScript to view this site.

A-Shell Reference

Navigation: Subroutines > XTREE > XTREE Techniques

Initial View Position

Scroll Prev Top Next More

If the tree control contains more rows and/or columns than can fit in the space determined by the srow, scol, erow and ecol parameters, vertical and/or horizontal scroll bars will automatically be added. By default, the initial scroll position will be at the top and to the left. Although there is no option to over-ride the scroll position directly, you can do it indirectly by specifying a row (or set of rows) to be selected, a cell to be edited, and/or a column to have the focus. The details for accomplishing this vary somewhat with the type of the tree.

For editable trees, the most direct way to establish the position is to set the XTR.TARGETROW and XTR.TARGETCOL parameters to the cell that you want to edit. This will force the cell to be brought into view (adjusting the vertical and horizontal scroll as needed). If these parameters are zero, then the initial position will be determined as it would for non-editable trees.

For non-editable trees, the vertical position will be determined by the initially selected item(s). For array-based trees, and file-based trees which are either multi-select or have the XTF_FILANS flag, this is determined by the value(s) passed in the answer parameter. For single-select file-based trees without the XTF_FILANS flag, the initially selected row is determined by the string in the array parameter. In all of these cases, XTREE will adjust the vertical scroll so that the selected item (or first selected item in the case of multi-selection) will be visible.

An exception to the above is that the combination of XTR.SKEY and XTR.COLUMNACTIVE may be used to select an initial item by searching for a matching string.

The horizontal scroll position (for non-editable trees, or when XTR.TARGETROW and XTR.TARGETCOL are zero) is determined by the XTR.COLUMNACTIVE parameter.

Note that item numbers and column numbers are always based on the initial order in which they are loaded or defined. Sorting and column reordering will obviously affect the display order, but will not affect the internal numbering. Thus, even if you select the first item and set the first column to be active, this could result in the tree being scrolled to the bottom and far right (or any other position) depending on the sorting and column reordering options.