Second, as shown in this answer to the linked question, you can use the SelectionColor and SelectionFont properties to change the style of text after selecting the target text. You should use Regex to find words in the string. I cannot get the misspelled word to be underlined individually.įirst of all, don't split the string by ' ' because this will treat 'Hello world', for example, as one word. an error appears saying 'String Does not contain definition for font'.
So when I replace it with: item.Font = new Font(item.Font, FontStyle.Underline)
The error appears to be in the line: GetRichTextBox().Font = new Font(GetRichTextBox().Font, FontStyle.Underline) GetRichTextBox().Font = new Font(GetRichTextBox().Font, FontStyle.Regular) GetRichTextBox().Font = new Font(GetRichTextBox().Font, FontStyle.Underline)
Using (Hunspell hunspell = new Hunspell('en_us.aff', 'en_US.dic'))įoreach (string item in sentence.Split(' ')) It seems to work fine, but when a misspelled word appears the entire RichTextBox gets underlined. I tried implementing the Hunspell spell-checker library to check my spelling as I type in my notepad application using c#.