# Programming With Table Identifiers

> Set table IDs with TableInsert, change them in the TableCreated event, keep them on reload and read cells with TableCellText, TableRows and TableColumns.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control ActiveX > Document Editor > Tables > Programming With Table Identifiers
- **793 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/llms-full.txt

---

A table identifier is the number by which your program addresses a table in a `TXTextControl`. With it, your code reads and changes the text and the attributes of a table from anywhere in the document, whether or not the input position is inside that table.

Identifiers are optional, but they are recommended whenever the program, rather than the end user, changes a table's text or attributes. Read on for how identifiers are assigned, when they survive saving and pasting, and which events report them.

### What a Table Identifier Is

A table has one of two kinds of identifier:

- **A user-defined identifier.** Your program sets it when it inserts the table with the [TableInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableinsert-method/llms-full.txt) method, in its optional `TableId` parameter, a number from 10 to 32,767. It doesn't need to be unique, and it remains valid when the table is saved and reloaded.
- **An identifier that TX Text Control selects.** When you set no identifier, TX Text Control returns one of its own. It is unique, but it does not remain valid when the table is saved and reloaded.

### Keep or Lose an Identifier When Tables Are Inserted

What happens to an identifier depends on where a table, or a part of one, is inserted:

- **Inside another table.** The inserted table becomes a part of the existing table, and its identifier is lost.
- **Outside of all existing tables, with a user-defined identifier.** A new table is created and its identifier remains valid. TX Text Control informs your program with the [TableCreated](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecreated-event/llms-full.txt) event that a new table has been created. To give the table a different identifier, set the event's *NewTableId* parameter.
- **From another application.** Such a table cannot have a user-defined identifier. TX Text Control sends an identifier it selected itself with the [TableCreated](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecreated-event/llms-full.txt) event, and your program can change it in the same way.

### Handle Tables Loaded From a Document

When tables are imported with the [Load](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/load-method/llms-full.txt) method, [TableCreated](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecreated-event/llms-full.txt) events occur only in two cases:

- the text is inserted into an existing document, or
- an imported table has no user-defined identifier.

A table with a user-defined identifier that is saved and reloaded raises no event.

### React When a Table Is Deleted

When a table is deleted completely, TX Text Control informs your program with the [TableDeleted](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tabledeleted-event/llms-full.txt) event.

### Access a Table by Its Identifier

The following properties take a table identifier. They get information about a table or set its attributes regardless of whether the current input position is inside this table:

| Member | Description |
|---|---|
| [TableCellText](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecelltext-property/llms-full.txt) | Gets or sets the text contents of a certain table cell. |
| [TableColumns](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecolumns-property/llms-full.txt) | Gets a table's number of columns. |
| [TableRows](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablerows-property/llms-full.txt) | Gets a table's number of rows. |

When more than one table with a certain identifier exists, these properties work with the originally inserted table. In a chain of linked windows, you can use them with any `TXTextControl` in the chain, regardless of which control contains the table.

### Related Pages

- [Tables](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/llms-full.txt): inserting tables, selecting cells and changing table attributes.
- [Using Formulas in Table Cells](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/formulas/llms-full.txt): formulas that address a cell by table identifier, row and column.
- [Number Formats](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/number-formats/llms-full.txt): formatting the results of cell formulas.

---

## Nearby

- **Previous:** [Tables](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/llms-full.txt)
- **Next:** [Using Formulas in Table Cells](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/formulas/llms-full.txt)
