标签:mat dex int 根据 oid value eve points form
方法一:鼠标点击波形
鼠标点击波形,显示点击位置的x,y值
private void chart1_MouseClick(object sender, MouseEventArgs e) //chart1是你建的chart控件,实际名字根据你自己代码里的命名
{
HitTestResult hit = chart1.HitTest(e.X, e.Y);
if (hit.Series != null)
{
var xValue = hit.Series.Points[hit.PointIndex].XValue;
var yValue = hit.Series.Points[hit.PointIndex].YValues.First();
textBox1.Text = string.Format("{0:F0},{1:F0}", "x:"+xValue, "y:"+yValue);//textbox1也是自己建的一个专门用来显示的内容框,也可以用messagebox直接弹出内容
}
else
{
textBox1.Text="未点击到波形曲线";
}
}
调用方法:
chart1.MouseClick += new MouseEventHandler(chart1_MouseClick);
方法二:鼠标移动到相应点位自动显示相关数值
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
var area = chart1.ChartAreas[0];
double xValue = area.AxisX.PixelPositionToValue(e.X);
double yValue = area.AxisY.PixelPositionToValue(e.Y);
textBox1.Text = string.Format("{0:F0},{1:F0}", xValue, yValue);
}
调用方法:
chart1.MouseMove += new MouseEventHandler(chart1_MouseMove);
Winform(C#)中Chart控件鼠标点击显示波形上相应点对应坐标轴的x,y值
标签:mat dex int 根据 oid value eve points form
原文地址:https://www.cnblogs.com/puffy/p/11440775.html