I would like to know if there's an easy way to implement spell check to my rich text box? I have heard there's a way to use the spell check from MS Word, but I would like to know if I could add an independent spell check to my application. If somebody could provide me with a tutorial on how to do this (video or webpage or example or anything), then I'd really appreciate it.
--EDIT--
Following on from the answer I received, I implemented the spell check to my code and it is now as follows:
private NetSpell.SpellChecker.Spelling spelling;
private NetSpell.SpellChecker.Dictionary.WordDictionary wordDictionary;
internal System.Windows.Forms.Button spellButton;
internal System.Windows.Forms.RichTextBox demoRichText;
private System.ComponentModel.IContainer components2;
internal System.Windows.Forms.RichTextBox Document;
internal NetSpell.SpellChecker.Spelling SpellChecker;
private System.ComponentModel.IContainer components1;
internal NetSpell.SpellChecker.Dictionary.WordDictionary WordDictionary;
...
private void toolStripButton1_Click(object sender, EventArgs e)
{
try
{
this.spelling.Text = this.richTextBoxPrintCtrl1.Text; // I get an error on this line.
this.spelling.SpellCheck();
}
catch
{
MessageBox.Show("Error loading Spell Checker. Please reload application and try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void spelling_DeletedWord(object sender, NetSpell.SpellChecker.SpellingEventArgs e)
{
int start = this.richTextBoxPrintCtrl1.SelectionStart;
int length = this.richTextBoxPrintCtrl1.SelectionLength;
this.richTextBoxPrintCtrl1.Select(e.TextIndex, e.Word.Length);
this.richTextBoxPrintCtrl1.SelectedText = "";
if (start > this.richTextBoxPrintCtrl1.Text.Length)
start = this.richTextBoxPrintCtrl1.Text.Length;
if ((start + length) > this.richTextBoxPrintCtrl1.Text.Length)
length = 0;
this.richTextBoxPrintCtrl1.Select(start, length);
}
private void spelling_ReplacedWord(object sender, NetSpell.SpellChecker.ReplaceWordEventArgs e)
{
int start = this.richTextBoxPrintCtrl1.SelectionStart;
int length = this.richTextBoxPrintCtrl1.SelectionLength;
this.richTextBoxPrintCtrl1.Select(e.TextIndex, e.Word.Length);
this.richTextBoxPrintCtrl1.SelectedText = e.ReplacementWord;
if (start > this.richTextBoxPrintCtrl1.Text.Length)
start = this.richTextBoxPrintCtrl1.Text.Length;
if ((start + length) > this.richTextBoxPrintCtrl1.Text.Length)
length = 0;
this.richTextBoxPrintCtrl1.Select(start, length);
}
private void spelling_EndOfText(object sender, System.EventArgs e)
{
Console.WriteLine("EndOfText");
}
However, when I try to load the checker, I get a NullReferenceExeption was unhandled error on the line uncommented in the code.
Any ideas? I don't know where to go from this point. I can load the program, but I get an error on the uncommented line of code. I've tried following the demo, but I can't seem to see why the demos code works but mine refuses to play nice... My code is exactly the same as the demo example (from what I can see), so why is it now working and giving me an error when I try to run the spell checker?