TX Spell .NET for Windows Forms

Spell Checking

Topic

The spell checker is connected and its dictionaries are found, yet a misspelled word stays unmarked, or a call of TX Spell .NET for Windows Forms throws an exception. Such problems come from the rules of the spell checker rather than from its installation: which words it checks, when TX Text Control asks it, and which calls it refuses while a dialog is open. When no word is marked at all, start with Spell Checking Doesn't Start and Dictionaries Not Found.

A Word Isn't Underlined While You Type It

In a TextControl, the word you are typing isn't underlined, although it is misspelled. It is underlined only after you type a space.

Since version 29.0 (X19) of TX Text Control, a word is checked once it is complete: when a delimiter such as a space or a period follows it, when the input position moves elsewhere, or when the document loses the focus. Earlier versions marked a word while it was still being typed. This is the intended behavior, not an error.

  1. Type a space or a period after the word, or click elsewhere in the document.
  2. Check that the word is underlined now.

As-You-Type Checking shows both behaviors side by side.

Some Misspelled Words Aren't Marked

Most misspelled words are marked, but some are not: words in capitals such as "NASA", words with digits such as "R2D2", e-mail addresses or URLs.

The spell checker skips these words by default, as What the Spell Checker Skips by Default describes. The defaults of IgnoreWord and IgnoreCase can also be changed by users, on the Spell Checking Options tab of the options dialog.

A word is also not marked when the user chose Ignore All for it, or added it to a user dictionary with Add To Dictionary.

  1. To check every word, set IgnoreWord to TXSpell.IgnoreWordSettings.Never:

    txSpellChecker1.IgnoreWord = TXTextControl.Proofing.TXSpell.IgnoreWordSettings.Never;
    
  2. To check capitalization strictly, set IgnoreCase to TXSpell.IgnoreCaseSettings.Never.

  3. Look for the word in the user dictionaries of the application, and remove it there if it doesn't belong.

Ignore Settings lists every value, and User Dictionaries describes the words users add.

Setting IgnoreCase or IgnoreWord Throws an Exception

Assigning a combination of values to IgnoreCase or IgnoreWord throws an exception.

Not every combination of the flags is valid: in IgnoreCase, Always, Never, WordBegin and WordBeginUpper exclude one another, and in IgnoreWord, Never can't be combined with any other value.

  1. Use at most one of Always, Never, WordBegin and WordBeginUpper in IgnoreCase.
  2. Use Never alone in IgnoreWord, or leave it out.

Ignore Settings lists every value and what it can be combined with.

A Call Throws While the Spell Check Dialog Is Open

A method of the spell checker throws an exception when your code calls it, for example from an event handler or a button that the user clicks while the spell check dialog is shown.

Some methods refuse to run while the SpellCheckDialog is open:

MethodThrows while the dialog is open
TXSpellChecker.CheckAlways
DictionaryCollection.Add and RemoveExcept for a UserDictionary added or removed in the options dialog that a button of the spell check dialog opened
DialogButtonCollection.Add, AddRange and RemoveAlways
  1. Load dictionaries and add or remove dialog buttons before the dialog is shown, for example when the form loads.
  2. Call Check before you open the dialog or after it is closed.

Loading and Managing Dictionaries and Customizing the Spell Check Dialog show where these calls belong.

OptionsDialog Throws an ArgumentException

Opening the options dialog with the list of tabs to show throws an ArgumentException.

The overloads of OptionsDialog that take activeTabs need at least one tab. The indices are zero-based: 0 is the spell checking options, 1 the dictionaries, 2 the hyphenation options and 3 the thesaurus files.

  1. Pass an array with at least one index, such as new int[] { 0 }.
  2. To show all tabs, call OptionsDialog() without activeTabs.

Options Dialog describes the tabs.

The SpellCheckText Event Isn't Raised

A handler of the SpellCheckText event of the TextControl is never called.

SpellCheckText is raised only when the SpellChecker property of the TextControl is null and IsSpellCheckingEnabled is true. When TX Spell .NET is connected, TX Text Control handles the event internally.

  1. To react to the words TX Spell .NET finds, use the events of the spell checker instead; see Events.
  2. To use a spell checker of your own, set SpellChecker to null and handle SpellCheckText.

TX Text Control .NET for Windows Forms describes the event.

The Spell Checker Isn't Initialized Without TX Text Control

A TXSpellChecker that checks a RichTextBox, a TextBox or text in code doesn't work as the samples show, while the same spell checker works with a TextControl.

Create initializes the resources of the spell checker and must be called before it is used. A connected TextControl calls it for you, and then it must not be called again. Without a TextControl, nothing calls it. The same applies to a TXSpell object, whose Create comes first as well.

  1. Call txSpellChecker1.Create() once, in the constructor of the form after InitializeComponent, when no TextControl is connected to the spell checker.
  2. Don't call it for a spell checker that the SpellChecker property of a TextControl refers to.

Check Spelling as You Type shows the call in a complete form.

The Document Editor Doesn't Mark Misspelled Words

In the Document Editor of TX Text Control .NET Server, no word is underlined, although the text contains misspelled words.

The editor checks spelling with TXTextControl.TXSpell.Core.SDK, which must be installed in the ASP.NET Core application that hosts the backend, and spell checking is off in the editor by default. getIsSpellCheckingEnabled returns true after it is switched on, even when no spell checker is present, so it doesn't tell you whether the package is found.

  1. Install TXTextControl.TXSpell.Core.SDK in the project that hosts the Document Editor backend, and rebuild it.
  2. Switch spell checking on, as Turn On Spell Checking shows.

Check That TX Spell .NET Is Found describes the symptoms of a missing package.