Page 1 of 1

Rectangle Tool Clicked - How to retrieve tool index

Posted: Fri Sep 09, 2011 11:45 am
by 16657923
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

Re: Rectangle Tool Clicked - How to retrieve tool index

Posted: Fri Sep 09, 2011 2:12 pm
by narcis
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());
    }

Re: Rectangle Tool Clicked - How to retrieve tool index

Posted: Fri Sep 09, 2011 3:15 pm
by 16657923
Thank you Narcis - Works fine for me :D

Regards,

Guilz