Formatting text
To make selected text bold, underlined, italic or strikethrough
you can use the following code:
|
Statement
|
Action
|
| RichTextBox1.SelBold = True |
Makes the selected text Bold |
| RichTextBox1.SelItalic = True |
Makes the selected text Italic |
| RichTextBox1.SelUnderline = True |
Makes the selected text Underlined |
| RichTextBox1.SelStrikeThru = True |
Makes the selected text Strikethrough |
To change the alignment, simply use this syntax:
RichTextBox1.SelAlignment = Alignment
Where alignment is one of the following constants:
|
Constant
|
Alignment
|
| vbRight |
Right |
| vbLeft |
Left |
| vbCenter |
Centre |
So, the following code will set make the selected text underlined, and aligned
to the right.
RichTextBox1.SelAlignment = vbRight
RichTextBox1.SelUnderline = True
If you want to know how to make a toolbar that shows the current underlined/italic/etc
state, click here.
-
Posted by mmarksbury on 24 Apr 2008
This is long past the topic post date but...
I used the selection method (where you select text and then update it), for formatting the output of an application's process in a RTF. ...
-
Posted by magiel on 06 Jan 2007
I am had the same proplems;
RichTextBox1.SelectionFont.Bold
RichTextBox1.SelectionFont.Underline etc are readonly
Solved them the following way
... -
Posted by Verdi on 21 Sep 2006
Kylua, your efforts were not wasted...
You have probably saved me a week's worth of head-pounding. Why it is so difficult to programmatically modify RTF using this control is beyond me. All...
-
Posted by Kylua on 31 Jul 2006
I spent AGES working thru this one and couldn't find it anywhere!
The basic problem is that you have to update the richtextbox.rtf, not .text.
And it is very fussy about goes in the...
-
Posted by vb_lover on 06 Dec 2005
James Crowley:
I am using vb6sp6(EM_SETTEXTMODE didn't work with vb6sp4 either) RTB control, I have already implemented URL detection similar to yours. However now i am trying to get MULTI-LEVEL U...