CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Rich text

  1. #1
    Join Date
    Mar 2001
    Location
    Romania
    Posts
    71

    Rich text

    I have a rich text control with the following code:

    With RtfBox
    .SelStart = 10
    .SelLength = 5
    .SelColor = vbRed
    .Text = .Text & "text"
    End With

    The problem is: after I add another text I loose the previous format.

    Thanks.

  2. #2
    Join Date
    Aug 2003
    Location
    Buenos Aires, Argentina
    Posts
    513
    What's your code?

  3. #3
    Join Date
    Oct 2003
    Location
    The Dutch Mountains
    Posts
    125

    I've tried it but.....

    I have tried your code but I don't see the problem.

    Works just fine
    Give up your guns and face the law!!

  4. #4
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Try using the .SelText property to allow .SelBold, .SelColor, .SelAlignment and all others format property to be applied only with the .SelText value, here is a quick example:

    Code:
        With Me.RichTextBox1
            .Text = ""
            .SelStart = 0
            .SelLength = 0
            .SelColor = vbRed
            .SelText = "RED"
            .SelStart = 3
            .SelLength = 0
            .SelColor = vbBlue
            .SelText = "BLUE"
        End With
    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

  5. #5
    Join Date
    Mar 2001
    Location
    Romania
    Posts
    71
    After you format the text, add some more text and you'll see that the previous format disappears.

    Thanks

  6. #6
    Join Date
    Mar 2001
    Location
    Romania
    Posts
    71
    Thanks

    It works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured