日期:2014-05-20 浏览次数:21324 次
private void chart1_MouseDown(object sender, MouseEventArgs e)
{
// Call Hit Test Method
HitTestResult result = chart1.HitTest(e.X, e.Y);
if (result.ChartElementType == ChartElementType.DataPoint)
{
DataPoint selectedDataPoint = (DataPoint)result.Object;
MessageBox.Show("X 值:" +selectedDataPoint.XValue + " Y 值: " + selectedDataPoint.YValues[0]);
}
else if (result.ChartElementType != ChartElementType.Nothing)
{
string elementType = result.ChartElementType.ToString();
MessageBox.Show(this, "Selected Element is: " + elementType);
}
}