24

Are there any libraries out there (preferably a self contained Text Edit Control) for .NET that have Spell Check capabilities. I would like to add the typical red underline to miss-spelled words in the edit area of my application.

Edit: To clarify, this is for WinForms

Adam Haile
  • 30,705
  • 58
  • 191
  • 286

11 Answers11

12

Aspell.Net looks nice, but does not seem to be maintained anymore. I could not get it to work on my machine.

After searching around SourceForge, I found NHunspell, which is a .Net port of the spell checker from OpenOffice.org. It provides methods to spell check, find synonyms, and hyphenate. Its actively maintained at this time, and comes with easy to understand sample code.

In the project's own words:

Spell Checker, Hypenation and Thesaurus: NHunspell

NHunspell is a free open source spell checker for the .NET Framework. C# and Visual Basic sample code is available for spell checking, hyphenation and synonym lookup via thesaurus.

NHunspell is based on Hunspell and brings the Open Office spell checking, hyphenation and thesaurus to the Microsoft® .NET Framework. NHunspell is a .NET (C#, VB) library and wraps the native libraries Hunspell, Hyphen and MyThes.

The integrated libraries are used in OpenOffice and work with the dictionaries published on OpenOffice.org. License

NHunspell is licensed under: GPL/LGPL/MPL. Free use in commercial applications is permitted according to the LGPL and MPL licenses. Your commercial application can link against the NHunspell DLLs.

NHunspell

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
9

Not a redlining control, but: Aspell.Net is a Free and Open Source .Net spell checking component. Based on the GNU Aspell project, Aspell.Net is one of the most powerful multi-lingual spelling engines available. The API is written in C# and communicates through a C++ wrapper around the Win32 Port of Aspell's C API.

Source repository at sourceforge, checked February 2010 (Tahnks, @magnifico).

May 2012, source no longer accessible... sorry.

gimel
  • 83,368
  • 10
  • 76
  • 104
6

NHunspellTextBoxExtender, created by William Winner works. Once added to your project, can be used to extend textboxes and rich textboxes (any control that inherits TextBoxBase). Source code is included as well.

http://www.codeproject.com/KB/recipes/NHunspellExtenderProvider.aspx

Michael
  • 1,865
  • 3
  • 21
  • 23
2

You didn't mention whether this was for web based use or a desktop app, but I have used netSpell in the past and had good success.

John Lemp
  • 5,029
  • 3
  • 28
  • 36
2

Telerik has a control for ASP.NET.

Greg
  • 23,155
  • 11
  • 57
  • 79
Omar Kooheji
  • 54,530
  • 68
  • 182
  • 238
2

****** Windows App-You can customize your own textbox Control, No Third Party Software Needed******

1-First open your application "Properties" in solution explorer, under the "Application" tab make sure "target framework" is set to ".Net Framework 4", NOT ".Net Framework 4 Client Profile".

2-Second right click your application in solution explorer and select "Add Reference...". Select the ".NET" tab then hold the control key and select the "WindowsFormsIntegration", "System.Design", "PresentationCore"," PresentationFramework", "WindowsBase","System.Xaml" and click "OK".

3-Third right click your application in solution explorer and select "Add"->"Class". Make a new class you can name it anything you like. Open the code for the class you just made and delete the code, not the file.

4-Forth copy and paste the following code into the class file you just made.

using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Forms.Design;

[Designer(typeof(ControlDesigner))]
class SpellCheckTextbox: ElementHost
{
    private TextBox box;

    public SpellCheckTextbox()
    {
        box = new TextBox();
        base.Child = box;
        box.TextChanged += (sender, e) => OnTextChanged(EventArgs.Empty);
        box.SpellCheck.IsEnabled = true;
        box.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
        this.Size = new System.Drawing.Size(100, 200);
    }
    public override string Text
    {
        get { return box.Text; }
        set { box.Text = value; }
    }

    [DefaultValue(true)]
    public bool Multiline
    {
        get { return box.AcceptsReturn; }
        set { box.AcceptsReturn = value; }
    }

    [DefaultValue(false)]
    public bool ScrollBars
    {
        get 
        {
            if (box.VerticalScrollBarVisibility == ScrollBarVisibility.Visible ||
                box.HorizontalScrollBarVisibility == ScrollBarVisibility.Visible)
            {
                return true;
            }
            else 
            {
                return false;
            }

        }
        set 
        {
            if (value)
            {
                box.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                box.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            }
            else
            {
                box.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
                box.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
            }

        }
    }

    [DefaultValue(false)]
    public bool WordWrap
    {
        get { return box.TextWrapping != TextWrapping.NoWrap; }
        set { box.TextWrapping = value ? TextWrapping.Wrap : TextWrapping.NoWrap; }
    }

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public new System.Windows.UIElement Child
    {
        get { return base.Child; }
        set { /* Do nothing to solve a problem with the serializer !! */ }
    }

}

5- Fifth, finally last step, compile the code, then drag and drop the new control "SpellCheckTextbox", that is located at the top of the "Toolbox" in design view onto your form.

Steve
  • 21
  • 4
2

RapidSpell worked great for me http://keyoti.com

1

Free .NET spell checker based around a WPF text box that can be used client or server side can be seen here

Full disclosure...written by yours truly with some help from stack overflow of course :)

Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
  • The code looks nice, but your component doesn't appear in the ToolBox even though SpellCheckTextBox extends TextBox. I take it this is a XAML only component and is not designed to work on WinForms ? – Kraang Prime Jan 25 '16 at 18:48
  • This is not a visual component. I wrote it to run on a server. You call into it with the text you want spell checked and it returns you the spelling mistake position as well as suggestions. It will run under winforms if you add the correct assembly references. It is a hack basically, utilising the wpf text box just to get at the underlying spell check control. The text box never appears on screen. – Aran Mulholland Jan 25 '16 at 19:02
  • Thank you for clarifying. For the method and purpose you specify, the code is good, and it was a blessing to see something 'clean' for a change on GitHub. If I may suggest, could you add in a WinForms control example with redlining support similar to the hosted control by Steve. – Kraang Prime Jan 25 '16 at 19:43
  • Yeah that's not going to happen for a couple of reasons: I don't know WinForms, secondly my personal belief is that anything these days that does not target the web or the cloud is a waste of time. Winforms will be mostly dead in a couple of years along with WPF. (Pity really, I am pretty good at WPF) When you look at the attention Micorosoft is giving these technologies it's easy to see the writing is on the wall. I would be more interested in doing a JavaScript control. If I was to do this I wouldn't extend this code, I would build a separate project that used this. Feel free to do that :) – Aran Mulholland Jan 26 '16 at 07:47
  • Thank you for clarifying your reasons for this. Personal thoughts, with Windows 10 for android/etc devices on the Horizon, and the extra effort they put forth to rewrite the graphics layer, combined with the lack of any real attention to the web development portion of visual studio or iis, I don't believe that everything will be wholly 'cloud' centric. I see more of a hybrid solution -- at least until the day that OS's are only a web-browser without any other layers. – Kraang Prime Jan 26 '16 at 18:13
  • Yeah I would probably change it to web, cloud or mobile. But when we are looking for a spell check control what we are probably talking about are business applications and I think that writing these for the desktop is a waste of time. People want platform agnostic applications and they don't want to have to worry about backups and having their own internal infrastructure. Just bring your laptop or tablet and you're good to go. – Aran Mulholland Jan 26 '16 at 21:04
  • As for Microsoft not putting much effort into web development in Visual Studio and IIS I think you are mistaken. ASP.NET MVC, node.js, OWIN and Katana and a heap of other cool tech is at the top if their priority list. Web development in Visual Studio is really easy and the deployment options are fast and easy to use. I would be trying to convince any company I work for to put their development effort in that direction. Even MYOB (a business accounting software) is moving to the cloud. People are starting to trust that their data is safe even if it is kept on other peoples computers. – Aran Mulholland Jan 26 '16 at 21:12
0

Infragistics has a spell checker control that can do spell checking on any control. I haven't used it myself, but you can download a trial version for free.

Rune Grimstad
  • 35,612
  • 10
  • 61
  • 76
0

Component One supply a component that does this but only as you type. I use it and it is very fast.

See here for more info

John
  • 29,788
  • 18
  • 89
  • 130
-1

FCKEditor is a nice text editor (web based). It has spellchecking capabilities.

Vinblad
  • 676
  • 1
  • 7
  • 18