moveColumn

moveColumn(src: Integer;
           dst: Integer);

The moveColumn method of the Table class can be used to move a column of the current sheet of a table. The following example of the moveColumn method moves column 4 to column 2. Column 2 becomes column 3, and column 3 becomes column 4.

table1.moveColumn(4, 2);

The following example of the moveColumn method moves column 2 to column 4. Column 3 becomes column 2, and column 4 becomes column 3.

table1.moveColumn(2, 4);

The current column is adjusted if that column is affected.

The methods in the following examples show the use of the moveColumn method.

comboBoxColMoveTo_click(combobox: ComboBox input) updating;
theTable_dragDrop(table: Table input;
                  win:   Window input;
                  x, y:  Real) updating;
// Dropping a column on the table causes the dragged column to be moved
// before or after the column it is dropped on, based on the move direction
vars
    count : Integer;
begin
    if win = table then
        count := convertPositionToColumn(x);
        if count <> 0 then
            win.Table.moveColumn(win.Table.column, count);
        endif;
        win.dragMode := DragMode_None;
    endif;
end;
begin
    if selectedColumn <> null then
        table1.moveColumn(selectedColumn, comboBoxColMoveTo.listIndex);
        selectedColumn := null;
        table1.clearAllSelected;
        buttonSort.setFocus;
    else
        app.msgBox("You must select a column", "No column selected!",
                   MsgBox_OK_Only);
        return;
    endif;
end;