Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET WinForm
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 11-Nov-10 7:07am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hello ;
kindly check that links :
link1[^]
link2[^]
get all what you want !!![^]
regards..
  Permalink  
Comments
Alan Burkhart at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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..
  Permalink  
Comments
Alan Burkhart at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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?
  Permalink  
Comments
tamerqatar at 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 at 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)

  Print Answers RSS
0 OriginalGriff 431
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Sergey Alexandrovich Kryukov 175
4 Marcin Kozub 175
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100