I'm using the VB.NET 2005 RichTextBox control as a base for a user control that I've written, and one of the functions I'm writing into this control is a spelling check. There's a problem I've found though: I can't preserve RTF markup when corrections to the spelling are made.

I've tried my own method of breaking the content up into an array and checking against a dictionary, as well as using MS Word (less ideal because now my control is dependent on having Word installed), but with both the only way I could get it to work at all was to use the Text property. This fails to handle any formatting the user had done to the text, so at the end of the spell check, everything is back to the default font. Bold text, colors, highlight, lists, etc. are lost.

A crappy way I found is to use MS Word, but use a temporary RTF file for the spelling check. Basically I save the content of the RTB into a temporary RTF file, load it with the Word object, run the spell check, save the changes, and then load it back into the RTB. That's a poor solution though, and it still has me bound to MS Word which I would like to avoid.

I'm certain that someone must have found/written/implemented a spelling check like this, so I'm hoping I can get some guidance on how to correctly approach this so I check the spelling of the box and retain all formatting that the user may have made.

Thanks. :)

Recommended Answers

All 2 Replies

>A crappy way I found is to use MS Word.

That is the only way.

>A crappy way I found is to use MS Word.

That is the only way.

That can't be the only way. How are other programs that don't depend on Word doing it? There must be some way to make corrections to the content in the control's RTF property so as to preserve formatting while correcting the spelling. I'm just not sure how to do it. I'm not suggesting that I think it's going to be easy to implement but someone must have some insight on how to most effectively go about doing this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.