TX Spell .NET for Windows Forms

TXSpellChecker Class

Class
Namespace
TXTextControl.Proofing
Package
TXTextControl.TXSpell.WinForms.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXSpell.Windows.Forms.dll
Install
dotnet add package TXTextControl.TXSpell.WinForms.SDK .NET 8 and later. For .NET Framework, reference TXSpell.Windows.Forms.dll from the setup.
Inherits
  1. Component
  2. TXSpellChecker

Description

The TXSpellChecker class implements a component with spell checking features. It allows to set general spell checking settings by using an options dialog, to invoke a customizable SpellCheckDialog that can be connected to different types of controls (e.g. TXTextControl.TextControl and System.Windows.Forms.RichtTextBox) and to create a spell checking context menu by using the TXSpellChecker.GetMenuItems method. Currently, TXTextControl (version 17.0 and better) provides the TextControl.SpellChecker Property to connect the TXSpellChecker with its TextControl component. To invoke the internal or an own spell check context menu on right clicking a misspelled word, the TextControl.SpellCheckContextMenuStrip Property must be set. The TXSpellChecker class is inherited from the System.ComponentModel.Component class. The following describes only the properties, methods and events defined through the TXSpellChecker class. For a list of properties, methods and events inherited from the System.ComponentModel.Component class see the .NET Framework reference.

Syntax

public sealed class TXSpellChecker : Component

Examples

The following example creates a TXSpell Checker instance and configures its dictionaries directory path setting for a document workflow.

using TXTextControl.Proofing.TXSpellChecker tXSpellChecker = new();
tXSpellChecker.DictionariesDirectoryPath = "document.docx";

Members

Constructors

ConstructorDescription
TXSpellCheckerInitializes a new instance of the TXSpellChecker class.

Properties

PropertyDescription
AvailableDictionariesGets a list of all available dictionaries in the default dictionary folder.
AvailableHyphenationListsGets a list of all available hyphenation lists of the default hyphenation lists folder.
AvailableSynonymListsGets a list of all available synonym lists of the default synonym lists folder.
DetectableLanguageScopesGets or sets a list of all languages that are used to detect language scopes in a text.
DictionariesGets a collection of all added and validated dictionaries. The property's value is an object of type DictionaryCollection.
DictionariesDirectoryPathGets or sets the path to the default dictionaries folder. The default value is "(Auto)" that determines the Dictionaries directory at the application's root folder or in the \Assembly\ subdirectory in the development machine's TX Spell .NET installation directory.
HyphenationLanguageGets or sets the name of a hyphenation list that is located at the default hyphenation lists folder. When using the HyphenationLanguage property, the Hyphenation.IsSelectedAsDefault property of the chosen hyphenation list is set to true. The default value is "(Auto)".
HyphenationListsGets a collection of all added hyphenation dictionaries. The property's value is an object of type HyphenationListCollection.
HyphenationListsDirectoryPathGets or sets the path to the default hyphenation lists folder. The default value is "(Auto)" that determines the HyphenationLists directory at the application's root folder or in the \Assembly\ subdirectory in the development machine's TX Spell .NET installation directory.
IgnoreCaseGets or sets a value of type IgnoreCaseSettings determining if and how the case of a word is ignored while spell checking. The default value is AllUpper | WordBeginUpper.
IgnoreWordGets or sets a value of type IgnoreWordSettings determining when a word should not be spell checked. The default value is InUpperCase | IsEmail | IsURL | WithNumbers.
IncorrectWordsGets a collection of all incorrect words that were detected by the last call of the TXSpellChecker.Check method. The property's value is an object of type IncorrectWordCollection.
LanguageGets or sets the name of a dictionary that is located at the default dictionary folder. Using the Language property, the Dictionary.IsSelectedAsDefault property of the chosen dictionary is set to true. The default value is "(Auto)".
LanguageRecognitionDirectoryPathGets or sets the path to the language recognition folder that provides the languageRecognition.resources file which is required to detect language scopes in a text. The default value is "(Auto)" that determines the LanguageRecognition directory at the application's root folder or in the \Assembly\ subdirectory in the development machine's TX Spell .NET installation directory.
LanguageScopesGets a collection of all detected language scopes. The property's value is an object of type LanguageScopeCollection.
SpellCheckDialogGets an object of type SpellCheckDialog that is used to modify and show the built-in SpellCheckDialog.
SpellingCorrectionUIProviderGets an object of type SpellingCorrectionUIProvider to provide methods and properties for constructing a spelling correction user interface.
SuggestionsGets a collection of suggestions that were created by the last call of the TXSpellChecker.CreateSuggestions method. The property's value is an object of type SuggestionCollection.
SynonymLanguageGets or sets the name of a synonym list that is located at the default synonym lists folder. When using the SynonymLanguage property, the SynonymList.IsSelectedAsDefault property of the selected synonym list is set to true. The default value is "(Auto)".
SynonymListsGets a collection of all added synonym lists. The property's value is an object of type SynonymListCollection.
SynonymListsDirectoryPathGets or sets the path to the default synonym lists folder. The default value is "(Auto)" that determines the SynonymLists directory at the application's root folder or in the \Assembly\ subdirectory in the development machine's TX Spell .NET installation directory.

Methods

MethodDescription
CheckChecks text for spelling errors and fills the IncorrectWordCollection at TXSpellChecker.IncorrectWords with all incorrect words. The first implementation uses selected dictionaries of the DictionaryCollection at TXSpellChecker.Dictionaries. The second implementation uses selected dictionaries of the TXSpellChecker.Dictionaries DictionaryCollection and the default dictionary folder where the dictionary's language equals to the defined language parameter. Only those dictionaries are used whose Dictionary.IsSpellCheckingEnabled properties are set to true.
CreateInitializes the resources of a newly instantiated TXSpellChecker object. This method must be called before using the object. If TX Spell .NET is connected to a TXTextControl.TextControl instance, this method is called implicitely and must not be called separately.
CreateSuggestionsDetermines suggestions for a specific incorrect word by using selected dictionaries of the DictionaryCollection at TXSpellChecker.Dictionaries and fills the results into the SuggestionCollection at TXSpellChecker.Suggestions. If no maximum number of suggestions is set, all created suggestions are added to TXSpellChecker.Suggestions. Otherwise, only the first maximum number of suggestions are determined. The second and fourth implementation uses selected dictionaries of the TXSpell.Dictionaries DictionaryCollection and the default dictionary folder where the dictionary's language equals to the defined language parameter. Only those dictionaries are used where the Dictionary.IsGetSuggestionsEnabled property is set to true.
CreateSynonymsReturns groups of synonyms that represent equivalent expressions for a specific text. The first implementation uses selected synonym lists of the SynonymListCollection at TXSpellChecker.SynonymLists. The second implementation uses selected synonym lists of the TXSpellChecker.SynonymLists collection and the default synonym lists folder where the synonym list's language equals to the defined language parameter. The last overload creates synonym groups for a specific synonym list. Only those synonym lists are used whose SynonymList.IsCreateSynonymsEnabled properties are set to true.
DetectLanguageScopesDetects language scopes in a text and fills the results into the LanguageScopeCollection at TXSpellChecker.LanguageScopes.
GetHyphenationPointReturns the next hyphenation point for a specific word right before a defined divide position. Using the first implementation that point is caluclated by applying the default hyphenation list. The second implementation uses a hyphenation list of the TXSpellChecker.HyphenationLists collection or a list from the default hyphenation lists folder that corresponds to the specified language parameter (second implementation). If there is no hyphenation point before that divide position and the position is less the word length, the method returns 0. For divide positions greater than or equal to the number of word characters, the method returns the word length.
GetHyphenationPointsReturns an array of all hyphenation points for a word. Using the first implementation these points are caluclated by applying the default hyphenation list. The second implementation uses a hyphenation list of the TXSpellChecker.HyphenationLists collection or a list from the default hyphenation lists folder that corresponds to the specified language parameter (second implementation).
GetMenuItemsReturns an array of MenuItems, which are used to create a custom spell check ContextMenu.
OptionsDialogInvokes the built-in dialog box to define spell check, create suggestions, hyphenation and create synonyms settings.

Events

EventDescription
DialogButtonClickedOccurs when a dialog button of the built-in SpellCheckDialog was clicked. The DialogButtonHandler receives an argument of type DialogButtonEventArgs containing data related to this event.
DictionaryAddedOccurs when a dictionary was added to the TXSpellChecker.Dictionaries DictionaryCollection. The DictionaryAddedHandler receives an argument of type DictionaryAddedEventArgs containing data related to this event.
DictionaryRemovedOccurs when a dictionary was removed from the TXSpellChecker.Dictionaries DictionaryCollection. The DictionaryRemovedHandler receives an argument of type DictionaryRemovedEventArgs containing data related to this event.
IncorrectWordChangingOccurs when an object of type IncorrectWord is changing by spell check context menu or spell check dialog operations. The IncorrectWordChangingHandler receives an argument of type IncorrectWordChangingEventArgs containing data related to this event.
MenuItemClickedOccurs when a MenuItem is clicked. The MenuItemClickedHandler receives an argument of type MenuItemClickedEventArgs containing data related to this event.
MisspelledWordChangingOccurs when an object of type TXTextControl.MisspelledWord is changing by spell check context menu or spell check dialog operations. The MisspelledWordChangingHandler receives an argument of type MisspelledWordChangingEventArgs containing data related to this event.
OptionsDialogOpeningOccurs when a the built-in options dialog is invoked by the TXSpellChecker.OptionsDialog method or clicking the Options... button of the built-in SpellCheckDialog. The OptionsDialogOpeningHandler receives an argument of type OptionsDialogOpeningEventArgs containing data related to this event.
SpellCheckDialogClosingOccurs when the built-in spell check dialog is closing. The SpellCheckDialogClosingHandler receives an argument of type SpellCheckDialogClosingEventArgs containing data related to this event.
SpellCheckDialogOpeningOccurs when the built-in spell check dialog is invoked using the SpellCheckDialog.Show method. The SpellCheckDialogOpeningHandler receives an argument of type SpellCheckDialogOpeningEventArgs containing data related to this event.
UserDictionaryWordAddedOccurs when a word is added to a user dictionary. The UserDictionaryWordAddedHandler receives an argument of type UserDictionaryWordAddedEventArgs containing data related to this event.
UserDictionaryWordRemovedOccurs when a word is removed from a user dictionary. The UserDictionaryWordRemovedHandler receives an argument of type UserDictionaryWordRemovedEventArgs containing data related to this event.