TX Spell .NET for Windows Forms

Create Your First Windows Forms Application

Topic

A word processor with spell checking takes two packages and a few clicks in the designer. You create a Windows Forms application for .NET, add TX Text Control with a ribbon, drop the TXSpellChecker of TX Spell .NET on the form and connect the two. Without a line of code, misspelled words are then underlined as you type, corrected from the context menu, and words are hyphenated at the end of a line.

Prerequisites

  • Visual Studio on Windows with .NET 8 or higher.
  • The setups of TX Spell .NET for Windows Forms 11.0 and TX Text Control .NET for Windows Forms 34.0, the full or the trial versions, installed on your machine. They provide the package source Text Control Offline Packages and the designers. See Installing the Product.

Create the Project

  1. Open Visual Studio and create a new project.

  2. Select C# from the Languages list, Windows from the Platform list and Desktop as the Project Type.

  3. Select the project template Windows Forms App and click Next.

    The Create a new project dialog of Visual Studio with the template Windows Forms App selected.

  4. Enter a project name and click Next.

  5. Select .NET 8 or higher as the Framework, for example .NET 8 (Long Term Support), and click Create.

The template Windows Forms App (.NET Framework) creates a .NET Framework project instead, which Create a .NET Framework Application covers.

Install the NuGet Packages

  1. Select the project in Solution Explorer and choose Project > Manage NuGet Packages....

  2. Select Text Control Offline Packages in the Package source list and click Browse.

  3. Select TXTextControl.TextControl.WinForms.SDK and click Install.

  4. Select TXTextControl.TXSpell.WinForms.SDK and click Install.

    The NuGet Package Manager of Visual Studio with the package source Text Control Offline Packages and the search term TXSpell, listing TXTextControl.TXSpell.Core.SDK and TXTextControl.TXSpell.WinForms.SDK, here in version 11.0.0, with the details of the Core package.

PackageAdds
TXTextControl.TextControl.WinForms.SDKThe TextControl editor, its ribbon and bars, and the license of TX Text Control
TXTextControl.TXSpell.WinForms.SDKThe TXSpellChecker component, its dialogs, the license of TX Spell .NET, and the US English dictionary, hyphenation list, thesaurus and language recognition data, which it copies into the output folder when you build

Package Overview describes the packages of TX Spell .NET.

Add the Editor to the Form

  1. Open Form1 in the designer from Solution Explorer.

  2. In the Toolbox, open the tab TX Text Control 34.0, select TextControl and draw the control onto the form.

  3. Click the smart tag in the upper right corner of the TextControl. In the Wizards group, click Add a Ribbon, Add a Status Bar, Add a Ruler and Add a Vertical Ruler.

    The TextControl Tasks smart tag of a TextControl on a form, with the Appearance section, the Information section with the version, here 31.0, and the Wizards section with links such as Add a Ribbon, Add a StatusBar, Add a Ruler, Add a Vertical Ruler and Arrange Controls Automatically.

  4. Click Arrange Controls Automatically. The controls are now connected to the TextControl and docked so that they fill the form.

  5. Select the ribbon by clicking its blue File tab title, and click the smart tag in the upper right corner of the ribbon.

  6. Click Add a RibbonFormattingTab, Add a RibbonInsertTab, Add a RibbonPageLayoutTab, Add a RibbonViewTab and Add a RibbonProofingTab.

    The Ribbon Tasks smart tag of the ribbon with the links Add a RibbonFormattingTab, Add a RibbonInsertTab, Add a RibbonPageLayoutTab, Add a RibbonViewTab and Add a RibbonProofingTab, and the Proofing tab already added.

The Proofing tab holds the commands of TX Spell .NET. The TX Text Control tutorial Create Your First Windows Forms Application describes the editor and its ribbon in more detail.

Add the Spell Checker

  1. In the Toolbox, open the tab TXSpell 11.0 and drag TXSpellChecker onto the form.

  2. The component has no user interface: it appears as txSpellChecker1 in the component tray below the form.

    The component tray below the form with txSpellChecker1.

Connect the Spell Checker

  1. Select the TextControl on the form.

  2. In the Properties window, open the drop-down list of SpellChecker and select txSpellChecker1.

    The Properties window of textControl1 with the SpellChecker drop-down open and txSpellChecker1 selected.

  3. Set IsSpellCheckingEnabled to True, to check spelling as the user types.

  4. Set IsHyphenationEnabled to True, to hyphenate words at the end of a line.

  5. Set IsLanguageDetectionEnabled to True, to detect the language of the text.

The application needs no code of your own: the designer writes these settings into Form1.Designer.cs. The settings work as follows:

Run the Application

Press F5 and type a sentence with a spelling mistake:

  • Each misspelled word gets a red zigzag line once it is complete. English is checked out of the box, with the dictionary the package copied into the output folder.
  • A right-click on a misspelled word opens the spell check context menu with suggestions, which also opens the spell check dialog.
  • When a line is full, its last word is hyphenated with the English hyphenation list.
  • The Proofing tab turns spell checking and hyphenation on and off, and offers commands to correct misspelled words, show synonyms, set and detect languages, and change the settings of spell checking, hyphenation and the thesaurus.

The Proofing tab of the ribbon with the buttons Enable Spell Checking, Enable Hyphenations, Thesaurus, Spelling, Load Dictionary, Load Thesaurus File and Manage Spelling & Hyphenation.

Troubleshooting

Next Steps