For this article we will assume we want the spell checker to ignore a 'header' region of 100 characters. RapidSpellDialog The simplest way to achieve this is to set the SelectionStart property in the text box to 100 immediately before calling RapidSpellDialog.Check(), this will cause the checker to start after the header. However, because the RapidSpellGUI (used by RapidSpellDialog) automatically wraps, you will find the checker querying the header at the end. To prevent this, override RapidSpellGUI; 1. Add a file with the following classes to your project Imports Keyoti.RapidSpell Imports System Imports System.Drawing Imports System.Windows.Forms 'Creates Instances of CustomGUI on demand, for RapidSpellDialog Public Class CustomUserInterfaceFormProvider Implements IUserInterfaceFormProvider Public Function CreateUserInterfaceForm() As IUserInterfaceForm Implements IUserInterfaceFormProvider.CreateUserInterfaceForm Return New CustomGUI End Function End Class 'Customized GUI layout Public Class CustomGUI Inherits RapidSpellGUI 'Prevent wrapping Protected Overrides Sub ProceedFromEnd() Me.End() End Sub End Class
2. Then in the place where you normally launch the spell checker, add;
Me.RapidSpellDialog1.UserInterfaceFormProvider = New CustomUserInterfaceFormProvider() eg. Private Sub CheckSpelling_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click Me.RapidSpellDialog1.UserInterfaceFormProvider = New CustomUserInterfaceFormProvider Me.RapidSpellDialog1.Check() End Sub RapidSpellAsYouType
Here we need to subclass RapidSpellAsYouType so we can override a method used to determine which areas of text are ignored. 1. Add new CustomRapidSpellAsYouType with override. Public Class CustomRapidSpellAsYouType Inherits Keyoti.RapidSpell.RapidSpellAsYouTypeAgent 'Force words before 100 to be ignored (important to allow text from MyBase to be ignored too) Protected Overrides Function IsInIgnorePos(ByVal pos As Integer) As Boolean Return pos < 100 Or MyBase.IsInIgnorePos(pos) End Function End Class
2. Handle a new event called NeedRapidSpellAsYouTypeAgent from RapidSpellAsYouType. Eg.
eg.
AddHandler rapidSpellAsYouType1.NeedRapidSpellAsYouTypeAgent, New Keyoti.RapidSpell.NeedRapidSpellAsYouTypeAgentEventHandler(rapidSpellAsYouType1_NeedRapidSpellAsYouTypeAgent) |