Code Project Prize winner in Competition "Best VB.NET article of October 2011"
Anyone wishing to use this code in their projects may do so, however are required to leave a post on this thread stating that they are using this.
A simple "I am using i00 Spell check in my project" will suffice.
DO NOT MIRROR
DO NOT LINK DIRECTLY TO THIS FILE - LINK TO THIS POST INSTEAD
DO NOT RE-DISTRIBUTE THIS SOURCE CODE PARTLY OR IN ITS ENTIRETY
20130521 - Download
Downloads per day:
I wanted a spell check that I could use in .Net, so like most people would have done, I Googled. After many hours of fruitless searching I decided to make my own; sure there are plenty of spell checkers out there, but I didn't want one that relied on 3rd party components such as Word or require Internet connectivity to work.
Introducing i00 .Net Spell Check, the first and only VB.net Spell Check written completely in VB! Not only that, it is also open source, and Easy to use.
Eventually, this project progressed even further into a generic control extension plugin that provides plugins for text box printing, translation, speech recognition and dictation plus more; while also providing a simple method for users to write their own extensions.
rykk - $30
Member 2262881 (POSabilities Inc.) - $100
Donate Here - and be sure to put "i00 Spell Check", your user name (or other alias), and if you want the amount disclosed in the description field
Users have been moved to their own post since the post size had been reached
Click here for users
Spell check with definitions
In-menu word definitions and Change to...
Adding words to dictionary
Custom content menus
Owner draw and RTB support
Spell check dialog
Support for DataGridViews!
Plugin support ... with label plugin
Plugin support ... with FastColoredTextBox plugin
To implement i00 .Net Spell Check into your project first either:
- add the i00SpellCheck project to your solution and reference it (recommended)
- reference the i00SpellCheck.exe file that is output from this project*
- or you can bring all of *.vb files in the "SpellCheck\Spell Check" folder (from the zip) directly into your own project*
NOTE: For the methods with the * you will need to also copy the dictionary files to the applications path
Next simply place this at the very top of your form:
* the code below may change if you used option 3 to "Imports YourProject.i00SpellCheck")
- Imports i00SpellCheck
Now you will be able to enable spell checking by placing the following in your form load event:
The above line will enable control extensions on all controls that are supported on the form, and all owned forms that are opened.vb Code:
Other examples are below:
- 'To load a single control extension on a control call:
- ControlExtensions.LoadSingleControlExtension(TextBox1, New TextBoxPrinter.TextBoxPrinter)
- 'To enable spell check on single line textboxes you will need to call:
- 'If you wanted to pass in options you can do so by handling the ControlExtensionAdding event PRIOR to calling EnableControlExtensions:
- AddHandler ControlExtensions.ControlExtensionAdding, AddressOf ControlExtensionAdding
- 'Also refer to the commented ControlExtensionAdding Sub in this form for more info
- 'You can also enable spell checking on an individual Control (if supported):
- 'To disable the spell check on a Control:
- 'To see if the spell check is enabled on a Control:
- Dim SpellCheckEnabled = TextBox1.IsSpellCheckEnabled()
- 'To see if another control extension is loaded (in this case call see if the TextBoxPrinter Extension is loaded on TextBox1):
- Dim PrinterExtLoaded = TextBox1.ExtensionCast(Of TextBoxPrinter.TextBoxPrinter)() IsNot Nothing
- 'To change spelling options on an individual Control:
- TextBox1.SpellCheck.Settings.AllowAdditions = True
- TextBox1.SpellCheck.Settings.AllowIgnore = True
- TextBox1.SpellCheck.Settings.AllowRemovals = True
- TextBox1.SpellCheck.Settings.ShowMistakes = True
- 'To set control extension options / call methods from control extensions (in this case call Print() from TextBox1):
- Dim PrinterExt = TextBox1.ExtensionCast(Of TextBoxPrinter.TextBoxPrinter)()
- 'To show a spellcheck dialog for an individual Control:
- Dim iSpellCheckDialog = TryCast(TextBox1.SpellCheck, i00SpellCheck.SpellCheckControlBase.iSpellCheckDialog)
- If iSpellCheckDialog IsNot Nothing Then
- End If
- 'To load a custom dictionary from a saved file:
- Dim Dictionary = New i00SpellCheck.FlatFileDictionary("c:\Custom.dic")
- 'To create a new blank dictionary and save it as a file
- Dim Dictionary = New i00SpellCheck.FlatFileDictionary("c:\Custom.dic", True)
- 'To Load a custom dictionary for an individual Control:
- TextBox1.SpellCheck.CurrentDictionary = Dictionary
- 'To Open the dictionary editor for a dictionary associated with a Control:
- 'NOTE: this should only be done after the dictionary has loaded (Control.SpellCheck.CurrentDictionary.Loading = False)
- 'Repaint all of the controls that use the same dictionary...
- ''This is used to setup spell check settings when the spell check extension is loaded:
- Private Sub ControlExtensionAdding(ByVal sender As Object, ByVal e As ControlExtensionAddingEventArgs)
- Dim SpellCheckControlBase = TryCast(e.Extension, SpellCheckControlBase)
- If SpellCheckControlBase IsNot Nothing Then
- Static SpellCheckSettings As i00SpellCheck.SpellCheckSettings 'Static for settings to be shared amongst all controls, use dim for control specific settings...
- If SpellCheckSettings Is Nothing Then
- SpellCheckSettings = New i00SpellCheck.SpellCheckSettings
- SpellCheckSettings.AllowAdditions = True 'Specifies if you want to allow the user to add words to the dictionary
- SpellCheckSettings.AllowIgnore = True 'Specifies if you want to allow the user ignore words
- SpellCheckSettings.AllowRemovals = True 'Specifies if you want to allow users to delete words from the dictionary
- SpellCheckSettings.AllowInMenuDefs = True 'Specifies if the in menu definitions should be shown for correctly spelled words
- SpellCheckSettings.AllowChangeTo = True 'Specifies if "Change to..." (to change to a synonym) should be shown in the menu for correctly spelled words
- End If
- SpellCheckControlBase.Settings = SpellCheckSettings
- End If
- End Sub
Even more examples are included in the Test projects included in the download .
Since version 20120618 i00SpellCheck has plugin support.
Plugins in i00SpellCheck allow components to be spell checked by making a dll or exe file that contains a public class that inherits i00SpellCheck.SpellCheckControlBase.
They automatically get picked up and allow the spellchecking of extra controls, with no reference to the file itself required. However you will need to place them in the applications path.
The use of plugins allow users to enable spellchecking of their controls, without having to change the i00SpellCheck project.
Another use for them could be to allow the programmer to quickly see if they have spelling errors on forms etc. For example placing the LabelPlugin.exe file in an application path (that already uses i00SpellCheck) will cause all labels in the existing project to be spell checked ... with NO code changes! When the developer wants to deploy their application they simply need to remove the LabelPlugin.exe file, and labels will no longer be corrected.
The basic procedures for creating a plugin are as follows:
- Start by creating a new project (class library or exe)
- Reference i00SpellCheck
- Make a class that inherits i00SpellCheck.SpellCheckControlBase
- Override the ControlType Property to return the type of control that you want your plugin to spell check
- Add your code
For examples on inheriting i00SpellCheck.SpellCheckControlBase check out the examples in the Plugins path in the download.
Version changes have been moved to their own post since the post size had been reached
Click here for version changes
Since the Textbox has no way to really draw on it "nicely" I used to capture the WM_PAINT of the control and then draw on the textbox graphics that was set by going Graphics.FromHwnd... this seemed to work well but produced a slight flicker that I thought was undesirable...
As of version 20120102 the render method now uses layered windows (by default), this basically means that all of the underlines that appear to be drawn on the control are actually drawn on another window over the top of the control ...
So how does this affect the user? Well in most cases it doesn't, the form is click-through and only the drawings are visible not the form itself. In fact if you press start + tab in Windows Vista/7 it even appears on the same window!
As I said above "in most cases"...
MIDI forms I haven't tested, but am quite sure that they won't work using the new render method.
Overlapping controls appear as follows:
And if the textbox is off the form the corrections appear to "Float" outside the form.
So in cases such as the above, you will have to go back to the older "compatible" rending, this can be done in these cases by going:
DirectCast(TextBox.SpellCheck, SpellCheckTextBox).RenderCompatibility = True
A special thanks to Pavel Torgashov for his excellent FastColoredTextBox control. This control is used in the solution to test i00SpellCheck's plugin architecture with 3rd party controls. i00 has not modified this control in any way and is only responsible for integrating the spell checking ability to it via an i00SpellCheck plugin. In no way is this control required for spell checking functions in other projects within the solution.
Thanks for downloading... Also please provide feedback, rate this thread and say thanks if this helped you
Suggestions on possible improvements are much appreciated
Also I extend a special thanks to the users who thanked / rated this post.