How Do I Get The Text To Be Aligned When I Press A Button
Thanx For All Your Help
Printable View
How Do I Get The Text To Be Aligned When I Press A Button
Thanx For All Your Help
from helpfile
peteQuote:
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
rtbMain.SelAlignment = rtfCenter 'aligns to the center
rtbMain.SelAlignment = rtfLeft 'aligns to the left
rtbMain.SelAlignment = rtfRight 'aligns to the right
Just to fill in a bit. You actually don't have to select any text, the SelAlignment property will align the paragraph the text caret is currently in. If more then one paragraph is fully or partially selected they are all aligned according to what you set the SelAlignment property to.