SpellChecking C1Chart

ComponentOne Studio for Winforms provides lot of utility controls to meet various requirements of the developers. Once such requirement from our customer was to spell check the strings inside the C1Chart Labels. This blog explains a small implementation to apply spell checking on a Chart object.

Implementing SpellCheck on C1Chart

C1Spellchecker control applies spell checking only on a control inheriting from TextBoxBase Class. Following steps summarizes the implementation to apply spell checking on C1Chart control.

  1. Create a TextBox type textcontainer object.
  2. Looping through the strings present on the Chart object.
  3. Passing each string to the textcontainer object.
  4. Spellchecking the text.
  5. Updating the spell checked string again to the chart object.

Here is how to do it in code :

private void ChartLabelChkbx_CheckedChanged(object sender, EventArgs e)  
    bool flag = false;  
    if (ChartLabelChkbx.Checked == true)  
        TextBox textContainer = new TextBox();  
        textContainer.Visible = false;  
        // If you set a location it may position dialog window  
        textContainer.Location = c1Chart1.Location;  
        foreach (C1.Win.C1Chart.Label l in c1Chart1.ChartLabels.LabelsCollection)  
            textContainer.Text = l.Text;  
            if (this.c1SpellChecker1.CheckControl(textContainer) > 0)  
                flag = true;  
                l.Text = textContainer.Text;  
        if (flag == false)  
            MessageBox.Show("SpellCheck complete !!");  

Click the image below to get a better understanding. Refer to the attached samples for complete implementation. Download Sample C# Download Sample VB


GrapeCity Developer Tools
comments powered by Disqus