[Note: if you want to PROGRAMMATICALLY spell check strings you should use the RapidSpellChecker class.]
A tempting approach would be to create a text box dynamically and not add it to your form, and then spell check that. However this is not lightweight, and unfortunately if you don't show your text box then the SelectionStart property returns -1, which is not acceptable - the spell checker relies on making selections to correct the text.
Dialog spell checking just a string can be acheived by creating an ISpellCheckableTextComponent class and spell checking an instance of that (the class just pretends to be a text box).
Eg. you would start the spell checker something like this;
Dim rapidSpellDialog As New Keyoti.RapidSpell.RapidSpellDialog()
'create an instance of the text box stand-in
Dim spellCheckable As New SpellCheckableComponent()
rapidSpellDialog.ShowFinishedBoxAtEnd = False
rapidSpellDialog.AlwaysShowDialog = False
rapidSpellDialog.Modal = True
rapidSpellDialog.TopMost = True
rapidSpellDialog.SizeGripStyle = SizeGripStyle.Hide
rapidSpellDialog.FormBorderStyle = FormBorderStyle.FixedDialog
rapidSpellDialog.ThirdPartyTextComponentToCheck = spellCheckable
'give the text box stand-in the string to check
spellCheckable.Text = "We wouldd like to spell check thiss string."
'invoke check - note this is modal based so it will block, if you change Modal to false you will need to use an event listener to listen to when the checking finishes.
rapidSpellDialog.Check()
'get the corrected text
MessageBox.Show("Corrected text: " & spellCheckable.Text)
You will need to add this class to your project:
Public Class SpellCheckableComponent
Implements Keyoti.RapidSpell.ISpellCheckableTextComponent
Public ReadOnly Property [ReadOnly]() As Boolean Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.ReadOnly
Get
Return False
End Get
End Property
Public ReadOnly Property Enabled() As Boolean Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.Enabled
Get
Return True
End Get
End Property
Sub dispose() Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.Dispose
theText = Nothing
End Sub
Public Event Disposed As EventHandler Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.Disposed
Private theText As New System.Text.StringBuilder()
Private hideSelection As Boolean = False
Private selStart As Int32 = 0
Private selLen As Int32 = 0
Public Sub New()
End Sub
Public Property Text() As String Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.Text
Get
Return theText.ToString
End Get
Set(ByVal Value As String)
theText.Remove(0, theText.Length)
theText.Append(Value)
End Set
End Property
Public Property myHideSelection() As Boolean Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.HideSelection
Get
Return hideSelection
End Get
Set(ByVal Value As Boolean)
hideSelection = Value
End Set
End Property
Public Event myGotFocus(ByVal sender As Object, ByVal e As EventArgs) Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.GotFocus
Public Property SelectedText() As String Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectedText
Get
Return theText.ToString.Substring(Me.SelectionStart, Me.SelectionLength)
End Get
Set(ByVal Value As String)
theText.Remove(Me.SelectionStart, Me.SelectionLength)
theText.Insert(Me.SelectionStart, Value)
End Set
End Property
Public Property SelectionStart() As Integer Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectionStart
Get
Return selStart
End Get
Set(ByVal Value As Integer)
selStart = Value
End Set
End Property
Public Property SelectionLength() As Integer Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectionLength
Get
Return selLen
End Get
Set(ByVal Value As Integer)
selLen = Value
End Set
End Property
Public Sub ScrollToCaret() Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.ScrollToCaret
'do nothing
End Sub
End Class