SetTab

Description

Modifies the alignment and position of a tab stop in a RichTextEdit control. If the specified tab stop does not exist, a new tab stop will be inserted.

Applies to

RichTextEdit controls

Syntax

rtename.SetTab (integer tabcurrent, integer tabtype, integer tabpos)

Argument

Description

rtename

The name of the RichTextEdit control in which you want to set the tab stop

tabcurrent

An integer indicating the order/sequence of the tab stop that you want to set.

If the tab stop specified by tabcurrent does not exist (for example, when there are only two tab stops, while tabcurrent is set to 3), a new tab stop will be inserted.

No more than 14 tab stops can be added and set, which means, valid value for tabcurrent is between 1 and 14. If invalid value is used, -1 will return.

The tabcurrent value for a tab stop will change if the order of the tab stop is changed (because the position can be modified by tabpos, and the position determines the order).

tabtype

An integer specifying the alignment of the tab stop. Possible values are:

1: Left-aligned tab stop -- The text will be aligned to the left when it reaches this tab stop.

2: Right-aligned tab stop -- The text will be aligned to the right at this tab stop.

3: Center-aligned tab stop -- The text will be centred at this tab stop.

4: Decimal-aligned tab stop -- Useful for aligning numbers with decimal points (e.g. for financial documents).

5: Rightmost tab stop -- The text will be placed at the furthest right edge, often used for right-aligned columns or data. tabpos will be ignored for this type.

tabpos

An integer specifying the position of the tab stop. This is the distance from the left margin where the tab stop will be placed. It is measured in twip (Twentieth of a Point).

When the position of a tab stop is changed, the order of existing tab stops may change as well, which means, the tabcurrent value of each tab stop may change too.


Return value

Integer.

Returns 1 if it succeeds and -1 if the value of tabcurrent or tabtype is invalid.

Examples

If there are more than one top stops, the following script modifies the first tab stop to be center-aligned and positioned at 1440 twips from the left margin.

If there is no tab stop at all, the following script inserts a tab stop at a position of 1440 twips from the left margin, with center alignment.

integer li_rtn
li_rtn = rte_1.SetTab (1, 3, 1440)

If there is only one top stop (center-aligned, at 1440 twips), the following script inserts a tab stop at a position of 100 twips from the left margin, with center alignment (because there is no second tab stop existing).

Note that after execution, the newly inserted tab stop's tabcurrent value is 1 (first in the order), not 2 (second), because of its position.

integer li_rtn
li_rtn = rte_1.SetTab (2, 3, 100)

See also

RemoveTab