****** 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.