4,816
社区成员
发帖
与我相关
我的任务
分享
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);
if(Result.Series!=null)
MessageBox.Show("'X轴:'" + Result.Series.Points[Result.PointIndex].XValue.ToString() + "'Y轴:'" + Result.Series.Points[Result.PointIndex].YValues[0].ToString());
}
}
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());
}
}
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