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

Thread: RTF class

  1. #1
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    RTF class

    ¿Is there a class to create and manipulate rtf formatted strings?

    I have a textbox, which I changed to a rtfbox.

    I create long and complex stringVariable, and the I write it to the textBox like:
    Code:
    MyTextBox.Text=stringVariable
    I would like to create a rtf formatted string, and maybe writing it with:
    Code:
    MyRichtextBox.rtf=stringVariable
    but it looks like appending and formatting rtf strings is complex.
    I can write to the rich text box utilizing .selection, appending and formatting string by string, but I suspect that it would be slow (was painfully slow with simple TextBox; that was the reason I created the StringVariable previously, and do the copying at the end.
    _

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: RTF class

    Take a look at this sample for a few things you can do with the RTB.

    EDIT: Just noticed that I posted VB6 code. It should work, and all methods still work as far as the RTB go.
    Attached Files Attached Files
    Last edited by dglienna; March 13th, 2008 at 09:16 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: RTF class

    Quote Originally Posted by dglienna
    Take a look at this sample for a few things you can do with the RTB.
    Tanks for your answer, but it look like I have not explained me well:

    I ported VB6 code to .NET 2008, and decided that since I need to recode a textBox related code, It would be worty to update to a richtTextBox, -to easy show colored warnings-

    I am looking for manipulation of rtf formatted strings without the rtf control, because I expect it to be to much slow, by all that overhead selecting things. And I not expect it to be fast to append new strings. (I recognize I have not experimented)

    I need to create long strings, and append data many times.

    Repeatedly adding strings to a string variable was really slow, because each time (VB6) added a new string, it reserved new memory, copied the strings, and freed the older.
    So I needed to create a longer string than needed (to avoiding reserving new memory each time, and copying the strings to append), and filling it with the mid() function, keeping track of the really utilised part of the string.

    but it not works with Rich Text strings, because they have strange codes (to allow all the rich formatting), so, I are looking for code to format and append rich text strings, since I (think) would need to change his memory reserving and appending routines, to avoid heavy string copying.
    I think that a class must be already available (or maybe .NET have that implemented), but I can’t found it with Google.

    _

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