This message contains graphics. If you do not see the graphics: Graphic Version.
 
Spell Checking in TX Text Control .NET for Windows Forms

We are often asked which spell checking control to use with TX Text Control. For several years, we have been recommending the VSSpell OCX control as it is both powerful and flexible. This control is now available as a .NET component.

This week we would like to show you how this success story continues with the just-released TX Text Control .NET for Windows Forms.

We are going to use the method CheckString from ComponentOne Spell for .NET with a plain text string that is saved by the TX Text Control in to a variable.

Dim sData As String TextControl1.Save(sData, TXTextControl.StringStreamType.PlainText) sData = sData.Replace(vbCr, "") C1Spell1.CheckString(sData, C1.Win.C1Spell.BadWordDialogEnum.EnglishDialog) C1Spell1.Clear()

If a mispelled word has been found by the spell checking component, the BadWord event is fired. It returns the character index and the length of the word which has to be selected by TX Text Control.

Private Sub C1Spell1_BadWord(ByVal sender As Object, ByVal e As C1.Win.C1Spell.BadWordEventArgs) Handles C1Spell1.BadWord TextControl1.Selection.Start = C1Spell1.SelStart TextControl1.Selection.Length = C1Spell1.SelLength End Sub

Now, the spell checker provides two change actions: The first changes the misspelled word to a selected word from the suggestion list and the second changes all words to that specified word. The DialogAction event returns the change state which indicates whether the 'Change' or 'Change All' button has been clicked. If 'Change All' has been clicked, all occurrences of the misspelled word will be searched in the document and will be replaced with the new word.

While (FindSuccess <> -1) TextControl1.Selection.Text = C1Spell1.DialogChangedWord NewPos = NewPos + TextControl1.Selection.Length FindSuccess = TextControl1.Find(C1Spell1.CheckWord, NewPos, TXTextControl.FindOptions.NoMessageBox) End While

If 'Change' has been clicked, only the selected word will be replaced.

TextControl1.Selection.Text = C1Spell1.DialogChangedWord

This sample application requires the following files to be downloaded and installed.

We wish you a lot of success with this sample application. As always, we are delighted to help you with any matter relating to TX Text Control. Call us or e-mail us! Full contact details at:


Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2003 Text Control GmbH. All Rights Reserved.