I am trying to use the SpellCheck class C# provides (in PresentationFramework.dll). But, I am experiencing problems when trying to bind the spelling to my textbox:
SpellCheck.SetIsEnabled(txtWhatever, true);
The problem is that my txtWhatever is of type System.Windows.Forms and the parameter this function is looking for is System.Windows.Controls, and simple converting failed. I also tried to make my TextBox of this type, but... couldn't. Does anyone know how to use this SpellCheck object? (MSDN wasn't that helpful...)
Thanks
I needed to add a background colour to the textbox in winforms that reflected the colour selected in the designer:
Have you tried just setting the property on the actual TextBox your attempting to spellcheck. e.g.
You have to use a WPF TextBox to make spell checking work. You can embed one in a Windows Forms form with the ElementHost control. It works pretty similar to a UserControl. Here's a control that you can drop straight from the toolbox. To get started, you need Project + Add Reference and select WindowsFormsIntegration, System.Design and the WPF assemblies PresentationCore, PresentationFramework and WindowsBase.
Add a new class to your project and paste the code shown below. Compile. Drop the SpellBox control from the top of the toolbox onto a form. It supports the TextChanged event and the Multiline and WordWrap properties. There's a nagging problem with the Font, there is no easy way to map a WF Font to the WPF font properties. The easiest workaround for that is to set the form's Font to "Segoe UI", the default for WPF.
By popular demand, a VB.NET version of this code that avoids the lambda:
Free .NET spell checker based around a WPF text box that can be used client or server side can be seen here. It will wrap the text box for you although you still need the assembly includes to Presentation framework etc.
Full disclosure...written by yours truly
You're trying to use a spell-check component designed for WPF on a WinForms application. They're incompatible.
If you want to use the .NET-provided spell check, you'll have to use WPF as your widget system.
If you want to stick with WinForms, you'll need a third-party spell check component.
what about getting a list of words in the english language and copying that to a text file. add the reference. then use streamreader class to analyze the list against textbox.text. any words not found in the text file could be set to be highlighted or displayed in a dialog box with options to replace or ignore. this is a shotgun suggestion with many missing steps and i am 2 months into programming but....its what im going to attempt anyway. i am making a notepad project (rexpad on idreamincode.com). hope this helped!