Scrolling Automatically to Selected Spell-Check Word
The following topic demonstrates how to automatically scroll to misspelled words within a multi-line text box. This topic assumes that you have created a new .NET project and added a C1Spell component to the project. Complete the following steps:
1. Place a TextBox control on the Windows Form.
2. Select the TextBox control, and from the Properties window set the following properties:
ScrollBars = Both
Text = "good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good good badd badd good"
Multiline = True
Size = 388, 35
Note: For the purpose of this example, the incorrect words (badd badd) have been added to the text, and are not in the visible area of the text box.
3. Place a Button control on the Form, below the TextBox control. Set the buttons Text property to "Spell Checking".
4. To enable spell-checking for the text in the TextBox control, double-click the Button control and add the following event handler for the Button_Click event:
C1Spell1.CheckControl(TextBox1)
C#
c1Spell1.CheckControl(textBox1);
5. To fire the BadWord event when an incorrect word is encountered, scroll the text box to this word, and then show the BadWordDialog, add the following code:
Private Sub C1Spell1_BadWord(ByVal sender As System.Object, ByVal e As C1.Win.C1Spell.BadWordEventArgs) Handles C1Spell1.BadWord
TextBox1.ScrollToCaret()
End Sub
C#
private void c1Spell1_BadWord(object sender, C1.Win.C1Spell.BadWordEventArgs e)
{
textBox1.ScrollToCaret();
}
This topic illustrates the following:
Run the application, and click the Spell Checking button. The text box scrolls to the bad word that is encountered during the spell check and the BadWordDialog is shown:
|