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
Checking type of tool
Hi Jenb
You can add and remove tools as below code:
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.
Re Checking ToolType
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
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
Dear Jenb
Also it's possible to control the type with the NET version, you can do it as below code:
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.