Checking type of tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Checking type of tool

Post by jenb » Thu Jun 28, 2007 8:49 am

I have just updated to TooChart .NET from the ActiveX control.

I am adding and removing varying numbers of different tools at run time. Previously I was using code like that below:

if (_tcChart.Tools.get_Items(i).ToolType == eChart.EToolClass.tcNearest)
_tcChart.Tools.Delete(i);

How can I perform similar functionality with the .NET version?

Thanks in advance.

jenb

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Jun 28, 2007 9:26 am

Hi Jenb

You can add and remove tools as below code:

Code: Select all

private void Form1_Load(object sender, EventArgs e)
        {
            bar1.FillSampleValues();

            //Add Tools
            Steema.TeeChart.Tools.ColorLine colorLine1 = new Steema.TeeChart.Tools.ColorLine(tChart1.Chart); //It will be the  tool number  0
            colorLine1.Active = true; 
            colorLine1.AllowDrag = true;
            colorLine1.Axis = tChart1.Axes.Left;
            colorLine1.Pen.Color = Color.Black; 
            colorLine1.Value = bar1.YValues.Maximum / 2;

            Steema.TeeChart.Tools.GridBand tool = new Steema.TeeChart.Tools.GridBand(tChart1.Chart); //It will be the tool number 1
            tool.Axis = tChart1.Axes.Left;
            tool.Band1.Color = Color.Red; 
            tool.Band2.Color = Color.White; 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Delete all tolls.
            for (int i = tChart1.Tools.Count -1; i >= 0; i--)
            {
                tChart1.Tools.RemoveAt(i);
            }
            tChart1.Invalidate(); //Necessary to repaint the chart.
        }
Last edited by Edu on Thu Jul 05, 2007 7:30 am, edited 1 time in total.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Re Checking ToolType

Post by jenb » Thu Jun 28, 2007 9:35 am

Dear Edu

Thanks for your reply.

I realise that I can add and remove all tools as in you example, however what if I just want to remove a particular tool, or tools, e.g. in your example the GridBandTool? I suppose that I could save the index value of the tool, or keep the tool object itself as a global variable, however in the ActiveX version of the TeeChart this wasn't necessary because I could just use the ToolType property.

Regards

Jenb

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Jun 28, 2007 10:15 am

Dear Jenb

Also it's possible to control the type with the NET version, you can do it as below code:

Code: Select all

            for (int i = tChart1.Tools.Count - 1; i >= 0; i--)
            {
                if (tChart1.Tools[i] is Steema.TeeChart.Tools.GridBand)
                        tChart1.Tools.RemoveAt(i);
            }
            tChart1.Invalidate(); //Necessary to repaint the chart.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

jenb
Newbie
Newbie
Posts: 50
Joined: Thu Jun 21, 2007 12:00 am

Post by jenb » Thu Jun 28, 2007 10:21 am

Thanks Edu

Yes I found some examples for checking the Series Type as well. Could be made clearer in the documentation though?

Best Regards

Jenb

Post Reply