CTools Add method

TeeChart for ActiveX, COM and ASP
Post Reply
nbp
Newbie
Newbie
Posts: 83
Joined: Mon Sep 18, 2006 12:00 am

CTools Add method

Post by nbp » Tue Mar 10, 2009 8:18 pm

I'm adding 2 tools to my chart (CrossHair Cursor and Mark Tips) with the following code:

long nInt1 = m_SelectedChart->GetTools().Add(tcCursor);
long nInt2 = m_SelectedChart->GetTools().Add(tcMarksTip);

What is the long returned by the Add method? Is it the position in the list of Tools? Or is it the tooltype (tcCursor or tcMarksTip)

Later I delete these tools from the ToolsList on the chart. If I don't have any other tools present, I delete the first 2 tools in the ToolsList. But if I have other tools present, how do I know which position in the list to delete?

m_SelectedChart->GetTools().Delete(???) What is the index I use here?

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Mar 11, 2009 9:11 am

Hi nbp,
nbp wrote:What is the long returned by the Add method? Is it the position in the list of Tools? Or is it the tooltype (tcCursor or tcMarksTip)
This method returns the index of the tool. The first will be the 0,...
nbp wrote:Later I delete these tools from the ToolsList on the chart. If I don't have any other tools present, I delete the first 2 tools in the ToolsList. But if I have other tools present, how do I know which position in the list to delete?
You could save the index of each tool when created and use it to identify the tool to delete. And the indexes should persist.

For example, the following works:

Code: Select all

int cursorIndex = axTChart1.Tools.Add(TeeChart.EToolClass.tcCursor);
int colorLineIndex = axTChart1.Tools.Add(TeeChart.EToolClass.tcColorLine);
int annotationIndex = axTChart1.Tools.Add(TeeChart.EToolClass.tcAnnotate);

axTChart1.Tools.Delete(colorLineIndex);
axTChart1.Tools.Delete(cursorIndex);
axTChart1.Tools.get_Items(annotationIndex).asAnnotation.Text = "my text";
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply