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.
答案 0 :(得分:2)
答案是在表单设计器中添加以下代码行:
(感谢jstreet的评论让我知道)
this.chart1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart1_MouseClick);