Project Description
WinForms TextBox with spell checking.

This WinForms control encapsulates the WPF textbox which has in built spell-checking. Only uses .net framework so you should be able to use this control without installing any extra libraries.


I currently work on Winforms applications in my job, and I am looking at WPF/Silverlight in my spare time. When I saw the spell checking features in the WPF TextBox I realized that this functionality would come in very useful in our applications. So I decided to try to add this functionality to a TextBox.

The way it works is by having a WPF user control that has a WFP textbox filling its own surface. This WPF user control is then embedded into a standard Winforms control, which is what you use in your application. Doing it this way meant that no extra files (dictionaries etc) needed to be included, file sizes are kept low, and installation is very simple.


The control was developed in Visual Studio 2010 and requires nothing except the .net 4.0 framework installed. The compiled DLL is small (approx 15k in size) and you can easily add extra functionality if required. If you need this control for an earlier version of .net you can probably compile the source against the relevant framework


Note there is a simple code sample that show the functions below being used. The main new functionality is listed below

SpellCheck bool

When set to true a red line is put under any mis-spelt words. Right clicking these words brings up a list of possible correct spellings

ChangedColor Color

You can set the text background Color to be displayed in a different Color if the user has changed the text in the text box by setting this property. If you do not want this feature set the ChangedColor to be the same as the BackColor.

OriginalText string

This is the original text value. If the text in the textbox is different from this value, then the background color will be displayed in a different color (ChangedColor). Also the TextHasBeenChanged property checks the Text property against this to determine whether the text has been changed.

SetValue string

This is used to initialize the textbox. It sets both the Text and OriginalText Property, so that the given text is displayed with the unchanged background color, and the textbox does not think that its value has been changed.

TextHasBeenChanged bool

Return true if the text has been changed (OriginalText property != Text Property)

AcceptsReturn bool

The text box accepts the return key

AcceptsTab bool

The textbox accepts tab (Pressing tab inserts a tab into the text and does not tab to the next input control)

TextType TextTypes

This can take one of 4 values:
TextTypes.String - Any value can be entered
TextTypes.Int - Only integer values can be entered
TextType.Currency - Currency/floating point numbers may be entered
TextType.Name - Any value can be entered, but the 1st letter of each word is capitalized so when entering names/addresses the word are capitalized correctly even if the user has not done it

Last edited Sep 18, 2011 at 11:25 AM by nick_le_page, version 6