Programming with Table Identifiers

Technical Articles > Tables

Each table can have an user-defined identifier which a programmer can set with the TableInsert method. Setting the identifier is not necessary but recommended when a table's text or attributes are to be changed from the program instead from an end-user. The user-defined identifier need not to be unique and remains valid if a table is saved and reloaded. When no identifier is set Text Control returns an own-selected one, which is unique and does not remain valid if a table is saved and reloaded.

When a table or a part of a table is inserted inside another table the inserted table becomes a part of the existing table and the inserted table's identifier is lost.

When a table with a user-defined identifier is inserted outside of all existing tables a new table is created and the table's identifier remains valid. Text Control informs the program with a TableCreated event that a new table has been created. The programmer can change the table identifier sent with the event by setting the NewTableId parameter of the event.

When a table is inserted from another application, which means it cannot have a user-defined identifier, Text Control sends an own-selected identifier with the TableCreated event and the program can change it.

When tables are imported with the Load method, TableCreated events occur only when text is inserted into an existing document or when an imported table has no user-defined identifier. Otherwise when a table with a user-defined identifier is saved and reloaded no event occurs.

When a table is completely deleted Text Control informs the program with a TableDeleted event.

The following properties and methods can be used with table identifiers to get information or to set table attributes regardless whether the current input position is or is not inside this table:

Property/Method Description
TableCellText Property Gets or sets the text contents of a certain table cell.
TableColumns Property Gets a table's number of columns.
TableRows Property Gets a table's number of rows.

When more than one table with a certain identifier exists, these properties and methods perform the operation with the original inserted table. In chains of linked windows these properties and methods can be used with any Text Control in the chain regardless of which control contains the table.