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:

  • %USERPROFILE%\My Documents\TX Spell 7.0.NET for Windows Forms\Samples\WinForms\CSharp\RichTextBox\Context menu strip
  • %USERPROFILE%\My Documents\TX Spell 7.0.NET for Windows Forms\Samples\WinForms\VB.NET\RichTextBox\Context menu strip

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.

TXTextControl.Proofing.MenuItem[] items = txSpellChecker1.GetMenuItems(currentIncorrectWord, richTextBox1.Text, 5);
Dim items As TXTextControl.Proofing.MenuItem() = txSpellChecker1.GetMenuItems(currentIncorrectWord, richTextBox1.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.

Image