MouseEvent not working in chart Area

1k views Asked by At

Chart

I am writing a program that gives a quick visual display of mySQL data, I would like to add a feature that gives the coordinates of the mouse location when the mouse is on the chart.

Problem is, ALL my mouse events ONLY work outside the chart area in red, anytime I try a mouse event such as: move/click/rightclick/scroll on the chart area itself (red area), it does not work.

Here is a simple piece of test code that I used:

    void chart1_MouseClick(object sender, MouseEventArgs e)
    {
          MessageBox.Show("");
    }

Clicking displays a message box only if clicked OUTSIDE the chart area (i.e. below the red box in the picure), however while the mouse is over the chart, nothing happens.

1

There are 1 answers

0
user3256369 On

The answer is to add this line of code in the Form Designer:

(thanks to comment by jstreet for letting me know)

this.chart1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart1_MouseClick);