How detect when series checkbox is selected in the legend?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 137
Joined: Mon Sep 22, 2008 12:00 am

How detect when series checkbox is selected in the legend?

Post by Dave » Thu Sep 25, 2014 1:51 pm

Hi

To display the checkboxes beside each series in the legend i do this;

theChart.Legend.CheckBoxes = true;


If the user selects a checkbox how do I detect this??

Note. I need to be able to detect whether the checkbox is selected or deselected


Note. I copied this questionto the activeX thread by mistake and Ive had a reply but this does not show how to detect the status of the box.
http://www.teechart.net/support/viewtop ... =1&t=15184

Christopher
Guru
Posts: 1192
Joined: Fri Nov 15, 2002 12:00 am

Re: How detect when series checkbox is selected in the legend?

Post by Christopher » Thu Sep 25, 2014 2:14 pm

Hello!

You could try something like this:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      for (int i = 0; i < 5; i++)
      {
        tChart1.Series.Add(typeof(Bar)).FillSampleValues();
      }

      tChart1.Legend.CheckBoxes = true;
    }


    private void button1_Click(object sender, EventArgs e)
    {
      int[] states = CheckCheckBoxStates();
      string s = "These CheckBoxes active: index(es) = ";

      for (int i = 0; i < states.Length; i++)
      {
        if (states[i] > 0)
          s += i.ToString() + " ";
      }

      MessageBox.Show(s);
    }

    private int[] CheckCheckBoxStates()
    {
      List<int> result = new List<int>();

      foreach (Series s in tChart1.Series)
      {
        result.Add(Convert.ToInt32(s.Active));
      }

      return result.ToArray();
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Dave
Advanced
Posts: 137
Joined: Mon Sep 22, 2008 12:00 am

Re: How detect when series checkbox is selected in the legend?

Post by Dave » Fri Sep 26, 2014 5:29 pm

Sensational! That works. Thanks Christopher

Post Reply