0

Hi everyone!

I have an application, where a user inputs some text in a RichTextBox.
I want to add a spell check, so first I have to store the words from the rtb. How to do it?

Thanks

2
Contributors
4
Replies
7
Views
8 Years
Discussion Span
Last Post by nkarvi
0

From my testing you can simply look at the richTextBox.Text property get the words without RTF formatting. Likewise you can access richTextbox.RTF to get the rich text.

string[] words = System.Text.RegularExpressions.Regex.Split(richTextBox1.Text, @"\W", System.Text.RegularExpressions.RegexOptions.Multiline);
0

Thank you very much snkake; it worked just fine. And sorry to bother you, but this brought another question:

once i had made the changes, how do i put the new data back in the original rtb?

Thanks again.

0

I did this in Delphi but I used the front end of the RTF component and searched for a word in the text and used SelectionStart/SelectionLength, called with rtb.Select(), to highlight the word and replaced it with the new word. This may be a problem if the first letter is bold and the subsequent letters are not -- i'm not sure off hand.

There are a lot of examples on spellchecking RTB's for C#. Have you checked them out?
http://www.c-sharpcorner.com/UploadFile/scottlysle/SpellCheckCC05152007084528AM/SpellCheckCC.aspx
http://www.wintertree-software.com/spell-check/csharp/index.html
(vb) http://www.planet-source-code.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!6269/lngWid!10/anyname.htm

Some rely on the office DLLs. I'm not sure if that is OK for this project

0

Thank you very much. I'll have a look at the links.

Thanks again

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.