ComponentOne SpellChecker for WinForms
In This Topic
    Customizing the Spell Dialog
    In This Topic

    The Spell Dialog can be customized three different ways:

    1. Create an instance of the C1SpellDialog class, attach event handlers, then pass the instance of the dialog to the CheckControl method. For example:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Private Sub btnSpell_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpell.Click
          ' create a spell-checking dialog box
          Using dlg As New C1SpellDialog()
              ' connect event handler
              AddHandler dlg.ErrorDisplayed, AddressOf dlg_ErrorDisplayed
                      ' spell-check the RichTextBox control
              C1SpellChecker1.CheckControl(Me.RichTextBox, False, dlg) 
          End Using 
      End Sub 
      Private Sub dlg_ErrorDisplayed(ByVal sender As Object, ByVal e As EventArgs)
          ' get the C1SpellDialog that fired the event
          Dim dlg As C1SpellDialog = TryCast(sender, C1SpellDialog) 
              ' show information about the error currently displayed
          ToolStripStatusLabel1.Text = String.Format("Error {0} of {1}: '{2}'", dlg.ErrorIndex + 1, dlg.ErrorCount, dlg.CurrentError.Text)
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void btnSpell_Click(object sender, EventArgs e)
      {
           // create a spell-checking dialog box
           using (C1SpellDialog dlg = new C1SpellDialog())
           {
                // connect event 
                 dlg.ErrorDisplayed += new EventHandler(dlg_ErrorDisplayed);
                 // spell-check the RichTextBox 
                c1SpellChecker1.CheckControl(this.richTextBox, 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
           toolStripStatusLabel1.Text = string.Format("Error {0} of {1}: '{2}'",
           dlg.ErrorIndex + 1, dlg.ErrorCount, dlg.CurrentError.Text);
      }
      
      Note that the code above assumes that you have added a Button control and a StatusStrip control with a ToolStripStatusLabel to your form at design time.

      OR

    2. Create a new spell-checking dialog class that implements the ISpellDialog interface. Then pass an instance of the new dialog to the CheckControl method.

      OR

    3. If you need more extensive customization, you can create your own spell dialog box and use that instead of the built-in one.
    Note: The samples that ship with the C1SpellChecker include a CustomSpellDialog application that includes the source code for two dialogs that you can use as a base for creating your own spell dialog boxes.