Knowledgebase Home Page  >  RapidSpell Desktop .NET  >  Behavior Customization
Search the Knowledge Base
Combobox spell checking in RapidSpellDialog. (C#)
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=239&catId=62

Options

Print this page
Email this to a friend

To make Combobox controls spell checkable, we implement the ISpellCheckableTextComponent interface in a simple wrapper class, that maps to the combobox.  This allows us to add the wrapper as a ‘textbox’ to be spell checked.


C# Code Example


  1. Add this class to the project

    using System;
    using System.Text;
    using Keyoti.RapidSpell;
    using System.Windows.Forms; 

    namespace Main
    {

        public class ComboBoxISpellCheckableWrapper : ISpellCheckableTextComponent

        {

            ComboBox comboBox;

            public ComboBoxISpellCheckableWrapper(ComboBox cb)
            {
                comboBox = cb;
                comboBox.GotFocus += 
    new EventHandler(comboBox_GotFocus);
                comboBox.Disposed += 
    new EventHandler(comboBox_Disposed);
            }
     

            void comboBox_Disposed(object sender, EventArgs e)
            {
                comboBox.GotFocus -= 
    new EventHandler(comboBox_GotFocus);
                comboBox.Disposed -= 
    new EventHandler(comboBox_Disposed);
                
    if (Disposed != null) Disposed(this, e);
            }
     

            void comboBox_GotFocus(object sender, EventArgs e)
            {
                
    if (GotFocus != null) GotFocus(this, e);
            }
     

            public void Dispose()
            {
                comboBox.Dispose();
            }
     

            public event EventHandler Disposed;
     
            
    public bool Enabled
            {
                
    get { return comboBox.Enabled; }
            }
     

            public event EventHandler GotFocus;
     
            
    public bool HideSelection
            {
                
    get
                {
                    
    return false;
                }
                
    set
                {
                    
    //cant map
                }
            }
     

            public bool ReadOnly
            {
                
    get { return false; }
            }
     

            public void ScrollToCaret()
            {
                
            }
     

            public string SelectedText
            {
                
    get
                {
                    
    return comboBox.SelectedText;
                }
                
    set
                {
                    comboBox.SelectedText = 
    value;
                }
            }
     

            public int SelectionLength
            {
                
    get
                {
                    
    return comboBox.SelectionLength;
                }
                
    set
                {
                    comboBox.SelectionLength = 
    value;
                }
            }

            public int SelectionStart
            {
                
    get
                {
                    
    return comboBox.SelectionStart;
                }
                
    set
                {
                    comboBox.SelectionStart = 
    value;
                }
            }
     

            public string Text
            {
                
    get
                {
                    
    return comboBox.Text;
                }
                
    set
                {
                    comboBox.Text=
    value;
                }
            }
        }

    }

     

  2. Use it like this

rapidSpellDialog1.AddTextComponent(new ComboBoxISpellCheckableWrapper(comboBox1));

(or by setting the ThirdPartyTextComponentToCheck property).

 


Related Questions:

Attachments:

No attachments were found.