Board index » Visual Studio » rich textbox loses formatting when printed to from 2 different subs

rich textbox loses formatting when printed to from 2 different subs

Visual Studio6
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


-
 

Re:rich textbox loses formatting when printed to from 2 different subs

"Mike Scirocco" <mscir@yahoo.com>wrote in message

Quote
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 - www.vbsight.com/ComGuard.htm">www.vbsight.com/ComGuard.htm





-

Re:rich textbox loses formatting when printed to from 2 different subs

Quote
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





-

Re:rich textbox loses formatting when printed to from 2 different subs

Quote
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





-

Re:rich textbox loses formatting when printed to from 2 different subs

Rick Rothstein wrote:

<snip>

Quote
Print? To a RichTextBox?



Sorry, poor choice of words, I'm adding text to a richtextbox. I'll try

the code suggestions, thanks.



Mike

-