Search code examples
infragisticsspell-checking

How to trigger red squigglies with UltraSpellChecker without user intervention?


The Infragistics docs say to set Mode to AsYouType and when the user types a space the spell checker will create the squigglies.

I also see there is an AsYouTypeManager class but don't know where or how to use it either. The documentation online is not that great.

When a box is loaded with the data and it has errors, I would like to have the red squigglies appear without any user interaction. How can I do this?


Solution

  • The following example shows how the UltraSpellChecker must be initialized to have the red squiggles appear without any user interaction.

    Form1.cs

    private void Form1_Load(object sender, EventArgs e)
    {
        // The extender property must be set for the rich text box so that it may be spell checked. 
        // This can also be done through the property grid in the forms designer
        this.ultraSpellChecker1.SetSpellCheckerSettings(this.rtbSpellChecked, new SpellCheckerSettings(true));
    }
    

    Form1.Designer.cs

    #region Windows Form Designer generated code
    
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.rtbSpellChecked = new System.Windows.Forms.RichTextBox();
        this.ultraSpellChecker1 = new Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker(this.components);
        ((System.ComponentModel.ISupportInitialize)(this.ultraSpellChecker1)).BeginInit();
        this.SuspendLayout();
        // 
        // rtbSpellChecked
        // 
        this.rtbSpellChecked.Dock = System.Windows.Forms.DockStyle.Fill;
        this.rtbSpellChecked.Location = new System.Drawing.Point(0, 0);
        this.rtbSpellChecked.Name = "rtbSpellChecked";
        this.rtbSpellChecked.Size = new System.Drawing.Size(411, 266);
        this.rtbSpellChecked.TabIndex = 5;
        this.rtbSpellChecked.Text = "UltraSpellChecker Class\nPerforms spel cheking on one or more conrols.";
        // 
        // ultraSpellChecker1
        // 
        this.ultraSpellChecker1.ContainingControl = this;
        this.ultraSpellChecker1.Mode = Infragistics.Win.UltraWinSpellChecker.SpellCheckingMode.AsYouType;
        this.ultraSpellChecker1.ShowDialogsModal = false;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(411, 266);
        this.Controls.Add(this.rtbSpellChecked);
        this.Name = "Form1";
        this.Text = "UltraSpellChecker";
        this.Load += new System.EventHandler(this.Form1_Load);
        
        ((System.ComponentModel.ISupportInitialize)(this.ultraSpellChecker1)).EndInit();
        this.ResumeLayout(false);
    
    }
    
    #endregion
    
    private Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker ultraSpellChecker1;
    private System.Windows.Forms.RichTextBox rtbSpellChecked;
    

    The this.ultraSpellChecker1.Mode is set to SpellCheckingMode.AsYouType as described in the Infragistics documentation and the code above shows the following form:

    enter image description here