RichTextBox Bolding, Italicizing, and Underlining 
Author Message
 RichTextBox Bolding, Italicizing, and Underlining

Hi there, does anyone know of any sample code for adding Bolding,
Italicizing, and Underlining (to selected text) functionality to a
RichTextBox control/application.

Thanks,
Jeremy



Mon, 10 Jan 2005 14:35:48 GMT  
 RichTextBox Bolding, Italicizing, and Underlining
If you start VB, select the VB Application Wizard, click Next and then click
Finish, VB'll generate a bare bones MDI word processor app for you using an
RTB.. The wizard also adds the code required for right/left alignment,
copy/paste, etc.. all of the basic stuff.. It's a good source for sample
code when starting out.

Here's a generic "snip"
'=============
Private Sub Form_Load()
   With RichTextBox1
      'Clear all
      .Text = ""
      .SelFontName = "Arial"
      .SelColor = vbRed
      .SelText = "This is red Arial text"
      .SelBold = True
      .SelColor = vbBlue
      .SelFontName = "MS Sans Serif"
      .SelText = "This is MS Sans Serif, blue and bold"
      .SelFontSize = 14
      .SelFontName = "Courier"
      .SelColor = vbGreen
      .SelText = "This is Courier bold, green and 14 points high"
   End With
End Sub
'=============

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm

Quote:

> Hi there, does anyone know of any sample code for adding Bolding,
> Italicizing, and Underlining (to selected text) functionality to a
> RichTextBox control/application.

> Thanks,
> Jeremy



Mon, 10 Jan 2005 22:26:00 GMT  
 RichTextBox Bolding, Italicizing, and Underlining
Hi there, does anyone know of any sample code for adding Bolding,
Italicizing, and Underlining (to selected text) functionality to a
RichTextBox control/application.

Thanks,
Jeremy



Mon, 17 Jan 2005 11:40:50 GMT  
 RichTextBox Bolding, Italicizing, and Underlining
Here's a quicky...
'==========
Private Sub Command1_Click()
   With RichTextBox1
      'Clear all
      .Text = ""
      .SelColor = vbRed
      .SelText = "This is red text" & vbCrLf
      .SelBold = True
      .SelItalic = True
      .SelColor = vbBlue
      .SelText = "This is blue, italic and bold" & vbCrLf
      .SelFontSize = 14
      .SelItalic = False
      .SelColor = vbGreen
      .SelText = "This is bold, green and 14 points high" & vbCrLf
      'Underline the word "green"
      .SelStart = .Find("green")
      .SelLength = 5
      .SelUnderline = True
   End With
End Sub
'==========

Also, if you start a new project and, instead of selecting "Standard EXE",
select "VB Application Wizard"... click Next, Finish... that'll give you the
code for a "bare bones" word processor.. including forms..etc. plus the code
that goes behind the standard word processor toolbar buttons.. like
left/right align, underlined, copy, paste, etc..

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> Hi there, does anyone know of any sample code for adding Bolding,
> Italicizing, and Underlining (to selected text) functionality to a
> RichTextBox control/application.

> Thanks,
> Jeremy



Mon, 17 Jan 2005 11:59:24 GMT  
 RichTextBox Bolding, Italicizing, and Underlining
This works, but for some reason when the control is databound it begins to
behave differently.  It will allow you to do one function (italicizing,
bolding, or underlining) and then any other functions will only return the
cursor to the home position until the datacontrol is reposition.

And ideas?


Quote:
> If you start VB, select the VB Application Wizard, click Next and then
click
> Finish, VB'll generate a bare bones MDI word processor app for you using
an
> RTB.. The wizard also adds the code required for right/left alignment,
> copy/paste, etc.. all of the basic stuff.. It's a good source for sample
> code when starting out.

> Here's a generic "snip"
> '=============
> Private Sub Form_Load()
>    With RichTextBox1
>       'Clear all
>       .Text = ""
>       .SelFontName = "Arial"
>       .SelColor = vbRed
>       .SelText = "This is red Arial text"
>       .SelBold = True
>       .SelColor = vbBlue
>       .SelFontName = "MS Sans Serif"
>       .SelText = "This is MS Sans Serif, blue and bold"
>       .SelFontSize = 14
>       .SelFontName = "Courier"
>       .SelColor = vbGreen
>       .SelText = "This is Courier bold, green and 14 points high"
>    End With
> End Sub
> '=============

> --
> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm


> > Hi there, does anyone know of any sample code for adding Bolding,
> > Italicizing, and Underlining (to selected text) functionality to a
> > RichTextBox control/application.

> > Thanks,
> > Jeremy



Mon, 17 Jan 2005 15:52:39 GMT  
 RichTextBox Bolding, Italicizing, and Underlining
Binding controls to a database... pretty much "binds" the developer to
whatever effects the datacontrol has on the control you're working with.
There are tons of examples around to help you get rid of that data control
and handle all db access with code only. This gives you back a lot of
control over what gets stored where, when and how. If you can't find samples
or a solution, check back.. I would say that a good place to start looking
would be CodeHound.com... but they seem to be, at least temporarily, zapped
so.. you may find something at vbdiamond.com or planet-source-code.com

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> This works, but for some reason when the control is databound it
> begins to behave differently.  It will allow you to do one function
> (italicizing, bolding, or underlining) and then any other functions
> will only return the cursor to the home position until the
> datacontrol is reposition.

> And ideas?



>> If you start VB, select the VB Application Wizard, click Next and
>> then
> click
>> Finish, VB'll generate a bare bones MDI word processor app for you
>> using
> an
>> RTB.. The wizard also adds the code required for right/left
>> alignment, copy/paste, etc.. all of the basic stuff.. It's a good
>> source for sample code when starting out.

>> Here's a generic "snip"
>> '=============
>> Private Sub Form_Load()
>>    With RichTextBox1
>>       'Clear all
>>       .Text = ""
>>       .SelFontName = "Arial"
>>       .SelColor = vbRed
>>       .SelText = "This is red Arial text"
>>       .SelBold = True
>>       .SelColor = vbBlue
>>       .SelFontName = "MS Sans Serif"
>>       .SelText = "This is MS Sans Serif, blue and bold"
>>       .SelFontSize = 14
>>       .SelFontName = "Courier"
>>       .SelColor = vbGreen
>>       .SelText = "This is Courier bold, green and 14 points high"
>>    End With
>> End Sub
>> '=============

>> --
>> Ken Halter - MS-MVP-VB - Please keep it in the groups..
>> http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm


>>> Hi there, does anyone know of any sample code for adding Bolding,
>>> Italicizing, and Underlining (to selected text) functionality to a
>>> RichTextBox control/application.

>>> Thanks,
>>> Jeremy



Mon, 17 Jan 2005 14:02:34 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. bold, italic and underline buttons.

2. Help: replace bold, italic and underline

3. How to maintain Bold font and underline in Text replacement

4. Applying a style turns off bold, italic, or underlining

5. Bold, italics, underline, strikeout at the same time

6. bold, underline and italic for a rtf-control

7. RFT to HTML Bold,Italic,Underline,Bullet

8. manipulating bold and underlined in the rich_text?

9. Bolding and Underlining Text

10. Toolbar icons (Bold, Underline, Italic, ...)

11. Bold/Italics and underline in an Editor box!!

12. bold, italic and underline buttons.

 

 
Powered by phpBB® Forum Software