Home > Archive > Visual Basic > April 2006 > rich textbox loses formatting when printed to from 2 different subs
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
rich textbox loses formatting when printed to from 2 different subs
|
|
| Mike Scirocco 2006-04-27, 6:56 pm |
| I'm using a rich textbox to let the user enter a few lines of text and
format them (font family, font size, italic, bold, color, underline).
Then I print a report to the rich textbox from a different sub on a
different form. When I do the textbox loses all of its formatting except
what was on the last line of the heading, and it applies that to the
whole textbox contents.
Is there a trick to this?
TIA
Mike
| |
| Ken Halter 2006-04-27, 6:56 pm |
| "Mike Scirocco" <mscir@yahoo.com> wrote in message
news:FoOdnTQmpvWxmczZRVn-gg@pghconnect.com...
> I'm using a rich textbox to let the user enter a few lines of text and
> format them (font family, font size, italic, bold, color, underline).
>
> Then I print a report to the rich textbox from a different sub on a
> different form. When I do the textbox loses all of its formatting except
> what was on the last line of the heading, and it applies that to the whole
> textbox contents.
>
> Is there a trick to this?
>
> TIA
> Mike
Post the code you're using to populate the box... you should be using
something like....
'==========
Public Sub AddSomeText(Text2Add As String, Optional AddCR As Boolean = True)
With RichTextBox1
'place the cursor at the end of all text
.SelStart = Len(.TextRTF)
'add the new text
.SelText = Text2Add
'optionally, add a cr/lf
If AddCR Then
.SelText = vbCrLf
End If
End With
End Sub
'==========
If you're using 'RichTextBox1.Text = RichTextBox1.Text & MoreText', you
won't be able to control formatting.
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
| |
| Rick Rothstein 2006-04-27, 6:56 pm |
| > I'm using a rich textbox to let the user enter a few lines of text and
> format them (font family, font size, italic, bold, color, underline).
>
> Then I print a report to the rich textbox from a different sub on a
> different form. When I do the textbox loses all of its formatting except
> what was on the last line of the heading, and it applies that to the whole
> textbox contents.
Print? To a RichTextBox? Also, what are you actually using... a RichTextBox
or a normal TextBox (see your sentence starting with "When I do the textbox
loses...")? Also, it would have been helpful if you had provided some code
so we wouldn't have to guess at what you are doing. Anyway, assuming you are
moving the contents of one RichTextBox to another RichTextBox, are you
assigning the Text property to the Text property or the TextRTF property to
the TextRTF property (which is what I think you may want)?
Rick
| |
| Rick Rothstein 2006-04-27, 6:56 pm |
| > If you're using 'RichTextBox1.Text = RichTextBox1.Text & MoreText',
> you won't be able to control formatting.
But you will with something like this...
RichTextBox2.SelRTF = RichTextBox1.TextRTF
Rick
|
|
|
|
|