positionLeft

positionLeft(): Integer;  (Table)

positionLeft(index: Integer): Integer;  (ListBox)

The positionLeft method of the Table control returns the displayed left position of the current cell in pixels, relative to the left of the client area of the table (the area inside borders).

The sheet, column, and row properties define the current cell. If the current cell is not visible, one or both of the positionLeft or positionTop methods returns -1. The positionLeft method of the ListBox control returns the displayed left position in pixels of the start of the text in the list box entry specified in the index parameter, relative to the client area of the ListBox control (that is, the area inside borders).

If the requested list entry is not valid, the positionLeft method returns -1.

The indicated position is for the text of the list entry and not for any pictures displayed before the text. (Use the getListIndex method to return the index of the displayed list entry corresponding to the specified x and y positions.)

The method in the following example shows the use of the positionLeft method to return the table column whose left and width position covers the x coordinate that is passed.

convertPositionToColumn(xPos: Real): Integer updating;
vars
    originalColumn : Integer;
    ix             : Integer;
begin
    originalColumn := theTable.column;
    ix             := theTable.leftColumn;
    while ix <= theTable.columns do
        theTable.column := ix;
        if theTable.positionLeft <= xPos then
            if xPos <= (theTable.positionLeft + theTable.columnWidth[ix])
                        then
                theTable.column := originalColumn;
                return ix;
            endif;
        endif;
        ix := ix + 1;
    endwhile;
    theTable.column := originalColumn;
    return 0;
end;