Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Using VB 2008 Express...

I'm aware that the .Net RichTextBox has numerous limitations. I wanted to build a simple editor, based on the RichTextBox, so that I could compose .rtf files within those limitations. I assumed that this would give me RTF content that would appear properly in a RichtextBox in other applications. Only took about an hour to build it. But...

When I set a background color for selected text and save the file (with RTB.SaveFile), then reopen it, the bkgnd color is preserved. But if I set a different color for the selected text (RTB.SelectionColor), the text is always the control's default text color when I reopen the file. It can't even properly read its own RTF.

So I created near-identical files with my editor, MS Works, AbiWord, WordPad and OpenOffice Writer. Of these programs, all could properly read their own RTF files, but almost none of them properly read each other's files (WordPad got it right in most but not all cases). And my RTF editor always opens a file with the RTB's default font regardless of the font it was saved in. OO Writer tends to lose bkgnd colors, and AbiWord was a train wreck.

So my question is: Is there some trick I'm missing? I was under the impression that RTF should appear at least mostly the same in any editor that supports it. I am open to ANY suggestions as to why I'm encountering the problem.
Posted

hello ;
kindly check that links :
link1[^]
link2[^]
get all what you want !!![^]
regards..
 
Share this answer
 
Comments
Alan Burkhart 11-Nov-10 13:00pm    
This doesn't really address the question. The links you offered cover the basics of using a RTB but don't address why every editor produces different results with the same file. Even when I reopen a file created in my own editor, it's changed from how it was when I saved it. It keeps bkgnd colors, but text colors are always set to the control's default (black) and all text is displayed in the control's default font. Some of the other editors also change the font to their own default when opening an rtf file created by another editor. Why?
you are sacing your files .rtf or .text??
but if you want to read a rtf you need a special parser control .. check that likn[^]
and that one[^] regards..
 
Share this answer
 
Comments
Alan Burkhart 11-Nov-10 17:31pm    
I'm just using the provided methods for reading and writing. RTB.SaveFile(path,streamtype) and RTB.LoadFile(path,streamtype). Look in Answer #3 - I just found part of the problem and it was a silly mistake on my part. That still doesn't explain why AbiWord, OOo, and the rest don't properly read each other's RTF files, though.
Figured out at least part of it. Had a hint from here.[^]

I was setting the default font and detecturl properties BEFORE reading the text when the app created a new RTB. Not real smart on my part. My rtf app now reads its own files correctly. It's still hit or miss as to how OO, AbiWord, Works and WordPad read each other's files. Maybe they're using different releases of the RTF Spec?
 
Share this answer
 
Comments
Tamer Hatoum 11-Nov-10 18:53pm    
that is great man, just take a look fro deferent versions of RTf in that link..
http://en.wikipedia.org/wiki/Rich_Text_Format
Alan Burkhart 11-Nov-10 20:39pm    
I'm betting that the different programs use different versions of RTF, although you'd think backwards compatibility would prevent such problems. I'm not going to lose any sleep over it. The main problem (in my own editor) is fixed and its only use is creating RTF for use in other RichTextBoxes. Thanks for taking the time to help. :-)

Here's some screen shots of what I saw while I was playing around with the other editors: http://www.alanburkhart.com/rtfissue.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900