日期:2014-05-20 浏览次数:21596 次
Private Sub Chart1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseDown
If e.Button <> Windows.Forms.MouseButtons.Right Then Exit Sub
Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)
If result.ChartElementType <> ChartElementType.DataPoint Then
Exit Sub
End If
Debug.Print(result.Series.Points(result.PointIndex).XValue.ToString & "," & result.Series.Points(result.PointIndex).YValues(0).ToString)
Exit Sub
private void chart1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
MessageBox.Show(chart1.Series[0].ToolTip.ToCharArray()[0].ToString());
}
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
System.Windows.Forms.DataVisualization.Charting.HitTestResult Result = new System.Windows.Forms.DataVisualization.Charting.HitTestResult();
Result = chart1.HitTest(e.X, e.Y);
MessageBox.Show("'X轴:'" + Result.Series.Points[Result.PointIndex].XValue.ToString() + "'Y轴:'" + Result.Series.Points[Result.PointIndex].XValue.ToString());
}