TX Text Control ActiveX

Tables

Topic

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 method, which inserts a new table in the text.
  • With the Load method, as part of a document in the RTF or HTML format.

To let users define the table, call TableInsertDialog 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.

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 method.

TXTextControl1 on a Visual Basic form with a table in which all cells of one column are selected

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 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.

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.

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:

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.

Key Members

MemberDescription
TableInsertInserts a new table in the text.
LoadLoads text in a certain format from a file and inserts it into the control.
TableDeleteLinesDeletes the selected table lines or the table line at the current input position.
TableAttrDialogOpens the built-in dialog box for table attributes.
TableCanChangeAttrTells whether the attributes of all selected table cells can be changed.
TableCanDeleteLinesTells whether table lines can be deleted.
TableCanInsertTells whether a table can be inserted.
TableCellFormulaReturns or sets the formula of a table cell.
TableCellNumberFormatReturns or sets the number format of a table cell.

Programming Categories - Tables lists all properties, methods and events for programming with tables.

Pages in This Section