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

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);

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.

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

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

Thanks again

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.