SelAlignment Property Example

This example uses an array of OptionButton controls to change the paragraph alignment of selected text in a RichTextBox control, but only if text is selected. The indices of the controls in the array correspond to settings for the SelAlignment property. To try this example, put a RichTextBox control and three OptionButton controls on a form. Give all three of the OptionButton controls the same name and set their Index property to 0, 1, and 2. Paste this code into the Click event of the OptionButton control. Then run the example.

Private Sub Option1_Click(Index As Integer)
   If RichTextBox1.SelLength > 0 Then
      RichTextBox1.SelAlignment = Index
   End If
End Sub