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

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Mike Scirocco" <mscir@xxxxxxxxx> wrote in message
news:FoOdnTQmpvWxmczZRVn-gg@xxxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: vb.net 2003 ... Global Formatting ?
    ... class and applies the correct formatting. ... extensions you need to make the perfect TextBox. ... Sub AddMyValidator ... Dim tb As TextBox ...
    (microsoft.public.dotnet.languages.vb)
  • Adding TextBox Shapes becomes slow
    ... I need to add about 200 TextBox Shapes to a document through Visual ... if you comment the formatting ... Dim wA As Word.Application ... End Sub ...
    (microsoft.public.word.vba.customization)
  • Adding TextBox Shapes becomes slow
    ... I need to add about 200 TextBox Shapes to a document through Visual ... if you comment the formatting ... Dim wA As Word.Application ... End Sub ...
    (microsoft.public.word.vba.general)
  • Re: Numeric Textbox Code
    ... This textbox checks the entered text upon the user leaving the textbox, ... Public Sub New ... 'This call is required by the Windows Form Designer. ... ' String representation of the RegEx that will be used to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How To Use The Number Part Of A TextBox Name As A Variable
    ... This requested code would need to detect what the name of the sub is ... The same demo shows how to process any textbox only by supplying its number ... Private Sub TextBox1_Enter' similar ... exiting the control. ...
    (microsoft.public.excel.programming)