ARTICLE

Spell checker in WPF using VB.NET

Posted by Rohatash Kumar Articles | WPF using VB.NET January 24, 2011
In this article we will learn how to use Spell checker in WPF using VB.NET.
Download Files:
 
Reader Level:

In this article we will learn how to use Spell checker in WPF using VB.NET.

Spell checker

The spell checker is used to check spelling of our content in WPF application.

Example

Taking a TextBlock control and RichTextBox control on the form.

The form looks like this.

sp.gif

Figure 1.

XAML code

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">

    <Grid>

        <TextBlock Height="23" HorizontalAlignment="Left" Margin="0,23,0,0" Name="TextBlock1" Text="Enter content:" VerticalAlignment="Top" Width="141" FontSize="18" Foreground="LawnGreen" />

        <RichTextBox Height="100" HorizontalAlignment="Left" Margin="0,44,0,0" Name="RichTextBox1" VerticalAlignment="Top" Width="200" Background="DodgerBlue" FontSize="18" />

    </Grid>

</Window>

 

Now double click on the RichTextBox and add the following code.

 

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles RichTextBox1.TextChanged

        SpellCheck.SetIsEnabled(RichTextBox1, True)

        SpellCheck.SetSpellingReform(RichTextBox1, SpellingReform.PreAndPostreform)

    End Sub

 

Now run the application and test it.

sp1.gif

Figure 2.

This can be done through the property of RichTextBox.

Set the property SpellCheck.IsEnabled="True" property in the RichTextBox after that automatically derive the Spell Checking functionality.

sp2.gif

Figure 3.

XAML code

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">

    <Grid>

        <TextBlock Height="23" HorizontalAlignment="Left" Margin="0,23,0,0" Name="TextBlock1" Text="Enter content:" VerticalAlignment="Top" Width="141" FontSize="18" Foreground="LawnGreen" />

        <RichTextBox Height="100" HorizontalAlignment="Left" Margin="0,44,0,0" Name="RichTextBox1" SpellCheck.IsEnabled="True" AcceptsReturn="True" VerticalAlignment="Top" Width="200" Background="Gold" FontSize="18" />

    </Grid>

</Window>

 

Now run the application and test it.

sp3.gif

Figure 4.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor