Rectangle Tool Clicked - How to retrieve tool index

TeeChart for ActiveX, COM and ASP
Post Reply
guilz2010
Newbie
Newbie
Posts: 63
Joined: Thu Nov 25, 2010 12:00 am
Location: Paris, France

Rectangle Tool Clicked - How to retrieve tool index

Post by guilz2010 » Fri Sep 09, 2011 11:45 am

Hi !

In our application, users can create as many rectangles as they want. How could we know the tool index of the rectangle clicked throw the event AxTChart_OnRectangleToolClick?

Thank for your answer

Guilz

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Rectangle Tool Clicked - How to retrieve tool index

Post by Narcís » Fri Sep 09, 2011 2:12 pm

Hi Guilz,

You can use tool's Clicked method, for example:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      axTChart1.AddSeries(TeeChart.ESeriesClass.scLine);
      axTChart1.Series(0).FillSampleValues();

      for (int i = 0; i < 5; i++)
      {
        axTChart1.Tools.Add(TeeChart.EToolClass.tcRectangle);
      }
    }

    private void axTChart1_OnRectangleToolClick(object sender, AxTeeChart.ITChartEvents_OnRectangleToolClickEvent e)
    {
      int index = -1;

      for (int i = 0; i < axTChart1.Tools.Count; i++)
      {

        if (axTChart1.Tools.Items[i].asRectangle.Clicked(e.x, e.y))
        {
          index = i;
          break;
        }
      }

      axTChart1.Header.Text.Clear();
      axTChart1.Header.Text.Add(index.ToString());
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

guilz2010
Newbie
Newbie
Posts: 63
Joined: Thu Nov 25, 2010 12:00 am
Location: Paris, France

Re: Rectangle Tool Clicked - How to retrieve tool index

Post by guilz2010 » Fri Sep 09, 2011 3:15 pm

Thank you Narcis - Works fine for me :D

Regards,

Guilz

Post Reply