Page 1 of 1

To show message on clicking downside to axis

Posted: Fri Nov 14, 2014 12:12 pm
by 9526439
Hi Steema Support,

Is it possible to show message box on clicking on the portion (downside of axis) of the axis. As shown in attached image.
please provide any solution for the same, it is very helpful to us.
Image1.png
Image
Image1.png (49.66 KiB) Viewed 4466 times
Thanks in advance.

Thanks&Regards
PlanoResearch

Re: To show message on clicking downside to axis

Posted: Mon Nov 17, 2014 10:38 am
by Christopher
Hello,

Try:

Code: Select all

    private void InitializeChart()
    {
      tChart1.MouseDown += tChart1_MouseDown;
      tChart1.Series.Add(typeof(Bar)).FillSampleValues();

      tChart1.AfterDraw += tChart1_AfterDraw;

      tChart1.Axes.Bottom.Title.Text = "bottom axes";
    }

    Rectangle rect;
    void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      rect = Utils.FromLTRB(tChart1.Axes.Bottom.IStartPos, tChart1.Axes.Left.IEndPos, tChart1.Axes.Bottom.IEndPos,
        tChart1.Axes.Bottom.Position + tChart1.Axes.Bottom.Labels.Height + tChart1.Axes.Bottom.Ticks.Length);

      g.Pen.Color = Color.Red;
      g.Brush.Visible = false;
      g.Rectangle(rect);
    }

    void tChart1_MouseDown(object sender, MouseEventArgs e)
    {
      tChart1.Chart.CancelMouse = true;
      if (tChart1.Axes.Bottom.Title.Clicked(e.X, e.Y))
      {
        MessageBox.Show("Title Clicked");
      }

      if(rect.Contains(e.X, e.Y))
      {
        MessageBox.Show("Axis Clicked");
      }
    }