clear

clear();

The clear method clears the contents of a ListBox or ComboBox control or the contents of the current sheet of a Table control.

The listCount method of a list box or combo box control then returns 0, following the clear method instruction.

For a table control, the clear method removes the contents of each cell of the current sheet of the table, including all cell properties (itemBackColor, itemForeColor, itemText, and so on). The number of rows and columns is retained, together with any row or column property values, which are reset to 1.

To clear the contents of an entire sheet, delete the sheet and then add it again (when the table has more than one sheet) or set the number of rows and columns to zero (0). The clear method detaches a collection from a control by clearing the displayCollection and the contents of the control.

The displayCollection method is not available in tables on forms in Web-enabled applications, as the HTML framework cannot predict the final size of your table and adjust the HTML page accordingly.

If you want to ensure that all possible entries in the table are displayed on a Web page, use some other "virtual window" for the Web generation or populate the table with all entries from the underlying collection if you know the number of rows will not cause excessive page size.

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

btnProcessLocks_click(btn: Button input) updating;
vars
    procs : ProcessDict;
    proc  : Process;
begin
    create procs transient;
    system.getObjectLockProcesses(obj, procs, 100);
    listBoxProcesses.clear;
    foreach proc in procs do
        listBoxProcesses.addItem(proc.userCode);
    endforeach;
end;

btnEdit_click(button: Button) updating;
begin
    if form.myCustomer <> null then
        listBoxCust.clear;
        loadListBox;
        btnEdit.enabled   := false;
        btnDelete.enabled := false;
    endif;
end;