Setting the edit type of a table columnΒΆ

table_set_type()

Set the edit type of a table column


SYNTAX

table_set_type(table_id, column, type [, drop_size, list_field])

Sets the edit type of a column of cells in a table. When a table is created, all the columns have the default type, TCT_READONLY, which means that cells in that column cannot be edited by the user. The table_set_type function is used to change this after the table has been created. The available edit types allow a cell to be edited using a textbox, a list button type listbox or list edit type listbox. See Listbox type.

Column numbering starts at 1, the far left column.

The type must be one of the following values, which are defined in <sculptor.h>:

TCT_TEXTBOX

Edit using a textbox.

TCT_DYNAMIC

The type will be set dynamically whenever the cell receives focus. This generates the EV_FOCUS_CELL event; the table event function must call table_set_type to set the edit type required. See Table events and functions.

TCT_LISTEDIT

Edit using a LIST_EDIT type listbox.

TCT_LISTBUTTON

Edit using a LIST_BUTTON type listbox.

TCT_READONLY

Cells in the column are read-only. This is the default.

The drop_size and list_field are only required if the type is TCT_LISTBUTTON or TCT_LISTEDIT.

The drop_size specifies the number of visible rows the listbox is to have. The default value is 5.

The list_field specifies an array field containing the list of permitted values.

The function returns a negative value if an error occurs, otherwise 0. Errors are caused by invalid arguments.


NOTES

  • From Sculptor 5.3 onwards, the cell_properties clause is the recommended method for assigning values to editable cells. This clause enables a record structure containing edit type, drop size, list field and other properties to be defined for an editable table column by assigning the required values to fields in the record. This effectively renders the table_set_type function obsolescent, though it will continue to be supported.

  • The table_set_default_data() function can be used to set a default value for all the cells in a column, to be displayed whenever the cell is edited.

  • If the edit mode flag EM_READONLY is set, cells in the table cannot be edited. This flag also prevents the user from selecting or deselecting lines in the table. See Table edit mode.


EXAMPLE

!file Scores data/scores read
!temp ScoreArray,,i4[8]

+table ScoreData at 15,5 {
    source_object = Scores
}

    create ScoreData
    table_set_type(ScoreData, 2, TCT_TEXTBOX)
    table_set_type(ScoreData, 4, TCT_LISTEDIT, 8, ScoreArray)

RELATED TOPICS

Listboxes

Tables

Textboxes

Table cell properties

Listbox and table functions