Spell Checker In WPF Using VB.NET

Here we see how to use spell checker to check our content and also display all its suggestion text.
  • 2913
Download Files:
 
Here we see how to use spell checker to check our content and also display all its suggestion text.

Spell checker

The spell checker is used to check spelling of our content in XAML, or The Spell checker returns you all its suggestions for your text.

Now creating a TextBlock control and RichTextBox control in XAML.

XAML code

<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" />

For example

Now creating TextBlock and RichTextBox control in XAML. The XAML code represents as following.

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="LightSalmon" FontSize="18" />

    </Grid>

</Window>

 

sp2.gif


Figure1.gif

 

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

Figure2.gif

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.