是否有任何具有拼写检查功能的 .NET 库(最好是自包含的文本编辑控件)。我想在我的应用程序的编辑区域中为拼写错误的单词添加典型的红色下划线。
编辑:澄清一下,这是针对 WinForms
是否有任何具有拼写检查功能的 .NET 库(最好是自包含的文本编辑控件)。我想在我的应用程序的编辑区域中为拼写错误的单词添加典型的红色下划线。
编辑:澄清一下,这是针对 WinForms
Aspell.Net 看起来不错,但似乎不再维护。我无法让它在我的机器上工作。
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.
不是红线控制,而是:Aspell.Net是一个免费和开源的 .Net 拼写检查组件。Aspell.Net 基于 GNU Aspell 项目,是可用的最强大的多语言拼写引擎之一。API 是用 C# 编写的,并通过围绕 Aspell 的 C API 的 Win32 端口的 C++ 包装器进行通信。
sourceforge的源代码库,2010 年 2 月检查(Tahnks,@magnifico)。
2012 年 5 月,源不再可访问...对不起。
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
你没有提到这是用于基于网络的使用还是桌面应用程序,但我过去使用过 netSpell并取得了很好的成功。
Telerik有一个针对 ASP.NET 的控件。
RapidSpell 对我很有效http://keyoti.com
****** 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.
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 :)
Infragistics有一个拼写检查控件,可以对任何控件进行拼写检查。我自己没用过,你可以免费下载试用版。
组件一提供了一个执行此操作但仅在您键入时执行的组件。我使用它,它非常快。
请参阅此处了解更多信息
FCKEditor 是一个不错的文本编辑器(基于网络)。它具有拼写检查功能。