ComponentOne SpellChecker for WinForms
C1.Win.SpellChecker.8 Assembly / C1.Win.SpellChecker Namespace / C1SpellChecker Class / CheckControl Method / CheckControl(TextBoxBase,Boolean,ISpellDialog) Method
System.Windows.Forms.TextBoxBase control that contains the text to be spell-checked.
Whether to check only from the cursor position or the entire control contents.
Dialog that implements the ISpellDialog interface used for displaying and correcting errors.
Example

In This Topic
    CheckControl(TextBoxBase,Boolean,ISpellDialog) Method
    In This Topic
    Shows a spell-checking dialog for an editor, returns the number of spelling errors found.
    Syntax
    'Declaration
     
    Public Overloads Function CheckControl( _
       ByVal editor As System.Windows.Forms.TextBoxBase, _
       ByVal fromCursor As System.Boolean, _
       ByVal dlg As ISpellDialog _
    ) As System.Integer
    public System.int CheckControl( 
       System.Windows.Forms.TextBoxBase editor,
       System.bool fromCursor,
       ISpellDialog dlg
    )

    Parameters

    editor
    System.Windows.Forms.TextBoxBase control that contains the text to be spell-checked.
    fromCursor
    Whether to check only from the cursor position or the entire control contents.
    dlg
    Dialog that implements the ISpellDialog interface used for displaying and correcting errors.

    Return Value

    The number of errors found, -1 if the dialog was canceled.
    Remarks
    You can use this method to invoke the spell-checker using a custom spell dialog, or using the built-in C1SpellDialog.
    Example
    The code below uses the CheckControl method with an instance of the C1SpellDialog and attaches some event handlers to display the spell-checking progress in a status bar.
    private void btnSpell_Click(object sender, EventArgs e)
    {
      // create spell-checking dialog
      using (C1SpellDialog dlg = new C1SpellDialog())
      {
        // connect event handler
        dlg.ErrorDisplayed += new EventHandler(dlg_ErrorDisplayed);
                
        // spell-check the 'textBox' control
        c1SpellChecker1.CheckControl(this.textBox, false, dlg);
      }
    }
    void dlg_ErrorDisplayed(object sender, EventArgs e)
    {
      // get the C1SpellDialog that fired the event
      C1SpellDialog dlg = sender as C1SpellDialog;
                
      // show information about the error currently displayed
      statusLabel1.Text = string.Format("Error {0} of {1}: '{2}'",
        dlg.ErrorIndex + 1, dlg.ErrorCount, dlg.CurrentError.Text);
    }
    See Also