|
-
Jan 7th, 2011, 11:17 PM
#1
Thread Starter
Member
Getting Formatted Text from a RichTextBox
Hey, everyone! I've decided to come back to working on an old program of mine, and it's been coming along nicely, but there's this one thing that I can't get working.
I have formatting options (Bold, Underline, Italics, Strikethrough) available on my program, and they all work properly. I'm giving users the ability to export all of their text from a single page on the program to a .rtf file. However, the problem I'm experiencing is that each page has numerous RichTextBoxes on it, so I cannot simply use a RichTextBox1.SaveFile() command or something similar. I want to compile all of the text (including formatting) from all of the RichTextBoxes and put it on a single .rtf file. Currently, I'm getting the text from the RichTextBoxes using the RichTextBox1.Text command; unfortunately, that only gives me plain text without formatting. So, what I'm wondering is: how can I get the formatted text from a RichTextBox? Is there any command?
Thanks, and any help would be greatly appreciated!
-
Jan 7th, 2011, 11:42 PM
#2
Re: Getting Formatted Text from a RichTextBox
As you say, the Text property gets just the text and not the markup. When you read the documentation for the RichTextBox class, you'd have noticed that the Rtf property is the one you use to get the markup and text.
I've never actually tried to combine the contents of multiple RTB controls. I'm not sure if it's as easy as simply concatenating the Rtf properties because each one probably contains its own root node. I've seen mention of classes designed to work with RTF data in code with no UI. I have no experience with any of them or even know where to find them, but if you search around you may be able to find one or more and they may be able to do what you want.
-
Jan 7th, 2011, 11:44 PM
#3
Re: Getting Formatted Text from a RichTextBox
http://www.bing.com/search?FORM=WLET....net+rtf+class
The fourth result there looks promising. The code is C# but you can reference a C# library in VB.
-
Jan 7th, 2011, 11:52 PM
#4
Thread Starter
Member
Re: Getting Formatted Text from a RichTextBox
Okay, thanks a lot! However, how would I reference this class? I've downloaded it, and it's just a bunch of separate Visual C# source files.
-
Jan 7th, 2011, 11:57 PM
#5
Re: Getting Formatted Text from a RichTextBox
As with your own source files, you must build the project to create an executable. If you don't want to look at and/or edit the source code then don't download the source code. Download the already-built executable.
-
Jan 8th, 2011, 12:25 AM
#6
Thread Starter
Member
Re: Getting Formatted Text from a RichTextBox
Well, I've downloaded it and used it, but it doesn't seem to do what I need.
-
Jan 8th, 2011, 12:39 AM
#7
Re: Getting Formatted Text from a RichTextBox
That may or may not be true. It may not have a single method that will do what you want in a single line but that doesn't necessarily mean that you can't achieve you aim with some combination of types and members. Then again, it may not be capable of doing what you need. I can't be of any more help than that I'm afraid as I've never used it or anything like it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|