Visual Basic: RichTextBox Control

SelAlignment Property

See Also    Example    Applies To

Returns or sets a value that controls the alignment of the paragraphs in a RichTextBox control. Not available at design time.

Syntax

object.SelAlignment [= value]

The SelAlignment property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
value An integer or constant that determines paragraph alignment, as described in Settings.

Settings

The settings for value are:

Constant Value Description
  Null Neither. The current selection spans more than one paragraph with different alignments.
rtfLeft 0 (Default) Left. The paragraph is aligned along the left margin.
rtfRight 1 Right. The paragraph is aligned along the right margin.
rtfCenter 2 Center. The paragraph is centered between the left and right margins.

Remarks

The SelAlignment property determines paragraph alignment for all paragraphs that have text in the current selection or for the paragraph containing the insertion point if no text is selected.

To distinguish between the values of Null and 0 when reading this property at run time, use the IsNull function with the If...Then...Else statement. For example:

If IsNull(RichTextBox1.SelAlignment) = True Then
   ' Code to run when selection is mixed.
ElseIf RichTextBox1.SelAlignment = 0 Then
   ' Code to run when selection is left aligned.
...
End If