C1SpellChecker with 3rd party textbox

Posted by: robert on 8 December 2022, 7:01 am EST

  • Posted 8 December 2022, 7:01 am EST

    Good day

    i am trying to implement spell checking on a 3rd party text box.

    i am trying to use textbox from DevExpress.

    i found this code (fot TXTextSpellChecker)

    'Connect spell-checker

    C1SpellChecker1.SetActiveSpellChecking(TxtTest, True)

    if gives error message

    ‘Unable to cast object of type ‘DevExpress.XtraEditors.TextEdit’ to type ‘C1.Win.C1SpellChecker.ISpellCheckableRichEditor’.’

    is it possible to use the C1SpellChecker with non C1 controls???

    Thanks in advance

  • Posted 9 December 2022, 12:55 am EST

    Hi Robert,

    As mentioned in the documentation at https://www.grapecity.com/componentone/docs/win/online-spellchecker/modesofspellchecking.html , If you are using a control that does not derive from Windows.Forms.TextBoxBase then you will have to create a wrapper class that implements the ISpellCheckableEditor or ISpellCheckableRichEditor interface depending on the mode you want to use.

    Regards.

  • Posted 9 December 2022, 2:45 am EST

    appreciate your comments above,

    looked at the link you provided, however

    i did not find any info on there that shows

    how to create this “ISpellCheckableEditor or ISpellCheckableRichEditor interface”

    that you refer to???

    do you have a sample in vb.net of this reference???

    never had to create a wrapper before??

    thanks for your help

  • Posted 12 December 2022, 3:07 am EST

    Hi,

    The interfaces ISpellCheckableEditor and ISpellCheckableRichEditor are included in the C1SpellChecker library.

    You need to do the following steps to create the wrapper:

    • Create a new class that inherits from the “Control” that you are using.
    • Implement the ISpellCheckableRichEditor in the class.
    • Define each property and method required as per the ISpellCheckableRichEditor interface.

    For example: The standard TextBox is already supported since it inherits from the TextBoxbase. But let’s assume it was a custom control that does not inherit from the TextBoxBase class. Then we will create the following class:

    Public Class TextBoxEx
        Inherits TextBox
        Implements ISpellCheckableRichEditor

    Then we will implement the members required by the ISpellCheckableRichEditor interface. Please refer to the sample attached.

    You can also refer to the product sample “SpellGrid” which shows how to create a wrapper class that implements the ISpellCheckableEditor interface on behalf of a C1FlexGrid control. Link : https://github.com/GrapeCity/ComponentOne-WinForms-Samples/tree/master/NetFramework/SpellChecker/CS/SpellGrid

    Regards

    Avnish

    C1SpellCheck_Ex.zip

  • Posted 12 December 2022, 1:17 pm EST

    1st thanks for the reply and sample.

    i managed to get it to work, but the misspelled words do not get the red underline.

    red underline

    only appears at beginning of the textbox and 1 char long???

    [code] Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    C1SpellChecker1.SetActiveSpellChecking(CType(TextEdit1, ISpellCheckableRichEditor), True)

    [code]Imports C1.Win.C1SpellChecker

    Imports DevExpress.XtraEditors

    Public Class TextEditEx

    Inherits TextEdit

    Implements ISpellCheckableRichEditor

    Public ReadOnly Property Control As Control Implements ISpellCheckableEditor.Control
        Get
            Return Me
        End Get
    End Property
    
    Public Property HideSelection As Boolean Implements ISpellCheckableEditor.HideSelection
        Get
            Return MyBase.Properties.HideSelection
        End Get
        Set(value As Boolean)
            MyBase.Properties.HideSelection = value
        End Set
    End Property
    
    Private Property ISpellCheckableEditor_Text As String Implements ISpellCheckableEditor.Text
        Get
            Return MyBase.Text
        End Get
        Set(value As String)
            MyBase.Text = value
        End Set
    End Property
    
    Private Property ISpellCheckableEditor_SelectedText As String Implements ISpellCheckableEditor.SelectedText
        Get
            Return MyBase.SelectedText
        End Get
        Set(value As String)
            MyBase.SelectedText = value
        End Set
    End Property
    
    Private Property ISpellCheckableEditor_SelectionStart As Integer Implements ISpellCheckableEditor.SelectionStart
        Get
            Return MyBase.SelectionStart
        End Get
        Set(value As Integer)
            MyBase.SelectionStart = value
        End Set
    End Property
    
    Private Property ISpellCheckableEditor_SelectionLength As Integer Implements ISpellCheckableEditor.SelectionLength
        Get
            Return MyBase.SelectionLength
        End Get
        Set(value As Integer)
            MyBase.SelectionLength = value
        End Set
    End Property
    
    Public Sub BeginSpell() Implements ISpellCheckableEditor.BeginSpell
    
    End Sub
    Public Sub EndSpell() Implements ISpellCheckableEditor.EndSpell
    
    End Sub
    
    Private Sub ISpellCheckableEditor_Select(start As Integer, length As Integer) Implements ISpellCheckableEditor.Select
        MyBase.Select(start, length)
    End Sub
    
    Public Function GetBaselineOffset(range As CharRange) As Integer Implements ISpellCheckableRichEditor.GetBaselineOffset
        Return Font.Height
    End Function
    
    Public Function HasMoreText() As Boolean Implements ISpellCheckableEditor.HasMoreText
        Return False
    End Function
    
    Private Function ISpellCheckableRichEditor_GetCharIndexFromPosition(pt As Point) As Integer Implements ISpellCheckableRichEditor.GetCharIndexFromPosition
        Return MyBase.GetCharIndexFromPosition(pt)
    End Function
    
    Private Function ISpellCheckableRichEditor_GetPositionFromCharIndex(index As Integer) As Point Implements ISpellCheckableRichEditor.GetPositionFromCharIndex
        Return MyBase.GetPositionFromCharIndex(index)
    End Function
    

    End Class

    [/code]

  • Posted 13 December 2022, 2:10 am EST

    Hi,

    We have escalated the issue to the development team and will let you know as soon as we have an update.

    [Internal Tracking ID : C1WIN-28763]

    Regards

    Avnish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels