# Tables

> Insert tables with TableInsert or Load from RTF and HTML, select and delete rows, open TableAttrDialog, check TableCanInsert and resize cells with the ruler.

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

---

Tables in a `TXTextControl` arrange text in rows and columns. Your program inserts them with a method or loads them with a document, users select and edit them like other text, and built-in dialog boxes and the ruler change their attributes and cell sizes.

What follows explains how TX Text Control organizes a table and which members insert, delete and format tables. The pages of this section go further: identifiers that address a table from code, formulas that calculate cell text and number formats that display the results.

### How Tables Are Organized

TX Text Control treats a table as a number of cells organized in rows and columns:

- **A cell holds text.** Each cell can have as many lines and paragraphs as required. Paragraph formatting is performed in relation to the cell's borders.
- **A cell has a position and an extension in the document.** Within this area, TX Text Control draws the cell's frames and its text with its paragraph and character formatting attributes. There can be a distance between the frame and the text.

### Insert Tables

A table gets into a `TXTextControl` in one of two ways:

- **With the [TableInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableinsert-method/llms-full.txt) method**, which inserts a new table in the text.
- **With the [Load](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/load-method/llms-full.txt) method**, as part of a document in the RTF or HTML format.

To let users define the table, call [TableInsertDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableinsertdialog-method/llms-full.txt) instead of `TableInsert`. It opens the built-in **Insert Table** dialog box and inserts the table when the user closes it with **OK**. It takes an optional table identifier and returns the identifier of the new table, -1 when the new table was combined with an existing table, or 0 when no table could be inserted, for example because text is selected.

![The built-in Insert Table dialog box of version 34.0 with the number of columns and rows, the column width options and the header row option.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/insert-table-dialog.13d1f799.webp)

When a table is inserted at the first position of another table or directly after another table, and both tables have the same number of columns, they are combined into a single table. Inserting one table inside another table is not possible.

### Select, Delete and Copy Table Text

Text can be selected within a single cell, or in steps of complete cells or rows. Deleting a selection inside a table deletes only the text. To delete one or more complete rows, use the [TableDeleteLines](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tabledeletelines-method/llms-full.txt) method.

![TXTextControl1 on a Visual Basic form with a table in which all cells of one column are selected](https://docs.textcontrol.com/assets/img/tx-text-control-activex/table-column-selected.6179be00.webp)

Tables can be copied to the clipboard and pasted from the clipboard.

### Change Table Attributes

The attributes of a table are its frame width, the distance between the frame and the formatted text, and its background color. To change the attributes of a table or a part of it, select the cells first. The [TableAttrDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableattrdialog-method/llms-full.txt) method then opens a built-in dialog box for them.

![The Frame and Color tab of the built-in Table Properties dialog box of TXTextControl with the frame, line width and color, background color and cell margins of the selected cells.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/table-properties-frame.06b6f594.webp)

![The Size and Formatting tab of the built-in Table Properties dialog box of TXTextControl with the cell height, the vertical alignment and the row options.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/table-properties-size.51893d3e.webp)

Attributes cannot be changed when the selection extends over several tables, or over tables and text. To find out whether attributes can be changed or tables can be inserted or deleted, for example to enable or disable the items of a menu, use these properties:

- [TableCanChangeAttr](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecanchangeattr-property/llms-full.txt) tells whether the attributes of all selected table cells can be changed.
- [TableCanDeleteLines](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecandeletelines-property/llms-full.txt) tells whether table lines can be deleted.
- [TableCanInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecaninsert-property/llms-full.txt) tells whether a table can be inserted.

### Resize Cells With the Ruler

When the current input position is inside a table, the ruler shows the positions of all cells in the table's row and the formatting attributes of the cell that contains the input position. Users can then change the positions and extensions of the cells with a built-in mouse interface.

![The horizontal TXRulerBar while the input position is in a table, with gray markers at the cell boundaries.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/ruler-table-cells.cf9aee3e.webp)

### Key Members

| Member | Description |
|---|---|
| [TableInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableinsert-method/llms-full.txt) | Inserts a new table in the text. |
| [Load](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/load-method/llms-full.txt) | Loads text in a certain format from a file and inserts it into the control. |
| [TableDeleteLines](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tabledeletelines-method/llms-full.txt) | Deletes the selected table lines or the table line at the current input position. |
| [TableAttrDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tableattrdialog-method/llms-full.txt) | Opens the built-in dialog box for table attributes. |
| [TableCanChangeAttr](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecanchangeattr-property/llms-full.txt) | Tells whether the attributes of all selected table cells can be changed. |
| [TableCanDeleteLines](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecandeletelines-property/llms-full.txt) | Tells whether table lines can be deleted. |
| [TableCanInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecaninsert-property/llms-full.txt) | Tells whether a table can be inserted. |
| [TableCellFormula](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecellformula-property/llms-full.txt) | Returns or sets the formula of a table cell. |
| [TableCellNumberFormat](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/tablecellnumberformat-property/llms-full.txt) | Returns or sets the number format of a table cell. |

[Programming Categories - Tables](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/tables/llms-full.txt) lists all properties, methods and events for programming with tables.

### Pages in This Section

- [Programming with Table Identifiers](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/llms-full.txt): addressing a table from code by its identifier.
- [Using Formulas in Table Cells](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/formulas/llms-full.txt): constants, operators, functions and cell references.
- [Number Formats](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/number-formats/llms-full.txt): placeholders, separators, percentages and text in results.

---

## In This Section

- [Using Formulas in Table Cells](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/formulas/llms-full.txt): Write TableCellFormula formulas with constants, operators, functions such as SUM, and A1 or R1C1 cell references, ranges and the LEFT, ABOVE and RIGHT flags.
- [Programming With Table Identifiers](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/llms-full.txt): Set table IDs with TableInsert, change them in the TableCreated event, keep them on reload and read cells with TableCellText, TableRows and TableColumns.
- [Number Formats](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/number-formats/llms-full.txt): Format formula results with TableCellNumberFormat: # and 0 placeholders, decimal and thousands separators, percentages, currency symbols and quoted text.

---

## Nearby

- **Previous:** [A Word Processor](https://docs.textcontrol.com/tx-text-control-activex/document-editor/word-processor/llms-full.txt)
- **Next:** [Programming With Table Identifiers](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/identifiers/llms-full.txt)
