Context Menus
Most users correct a misspelled word without leaving the text: they right-click the underlined word and choose the right spelling from a menu. With TX Text Control, TX Spell .NET provides this menu without any code. When you need other items in it, or a menu for another control, you build one from ready-made menu items. The sections below cover the built-in menu, how to replace it, how to build your own and how to react to its items.
What the Items Do
The Type of each MenuItem is a value of TXSpell.MenuItemType, and it decides what a click does:
| Type | What a click does |
|---|---|
Suggestion | Replaces the misspelled word with the text of the item |
IgnoreOnce | Ignores this occurrence of the word |
IgnoreAll | Ignores every occurrence of the word |
AddToDictionary | Adds the word to all editable user dictionaries |
Delete | Removes the word from the text |
NoSuggestions | Nothing; the item says that no suggestions were found |
After each click, the MenuItemClicked event of the TXSpellChecker reports the item, for example to log words that users add:
txSpellChecker1.MenuItemClicked += (sender, e) =>
{
if (e.MenuItem.Type == TXSpell.MenuItemType.AddToDictionary)
{
statusLabel.Text = "Word added to the dictionary.";
}
};
MenuItem of the MenuItemClickedEventArgs is the clicked item. statusLabel stands for a label of your form. Events lists the other events a correction raises.
Next Steps
- Synonyms in the Context Menu: offer synonyms of a word from a menu.
- Spell Check Dialog: the dialog of TX Spell .NET that the menu can open.
- Options Dialog: the dialog behind Options....
- Localization and Resource Kit: the texts of TX Spell .NET in other languages.
- Events: react to the corrections made in the menu.


