RichTextBox: Using a custom spell check ContextMenu

When TX Spell .NET is connected to a TextControl through the SpellChecker property, TextControl provides a pre-defined spell check context menu that can be used to replace the misspelled word, open the SpellCheckDialog or to open the options user dialog. But sometimes, it is required to create a customizable context menu or to include the spell check menu items into an existing menu.

The source code is contained in the following directories:

Using the Check method

TX Spell .NET provides the GetMenuItems method that returns ready-to-use menu items that can be inserted into an existing ContextMenuStrip. The method accepts a misspelled word, the text of the RichTextBox instance and the maximum number of returned suggestions.

[C#]
TXTextControl.WPF.Proofing.MenuItem[] items = txSpellChecker1.GetMenuItems(
	currentIncorrectWord,
	new TextRange(richTextBox1.Document.ContentStart,
	richTextBox1.Document.ContentEnd).Text, 5);
[Visual Basic]
Dim items As TXTextControl.WPF.Proofing.MenuItem() = txSpellChecker1.GetMenuItems( _
	currentIncorrectWord, _
	New TextRange(richTextBox1.Document.ContentStart, _
	richTextBox1.Document.ContentEnd).Text, 5)

TX Spell .NET provides different MenuItemTypes for different purposes such as deleting, ignoring or to add a word to a user dictionary.

Start the sample application and right-click on a misspelled word. You can replace the misspelled word with a correct suggestion, you can ignore it or you can add it to the user dictionary.