C# Chart控件鼠标悬停在表格矩形区域时显示坐标

2025-01-07 04:23:30
推荐回答(3个)
回答1:

Chart1控件不太用,你可以看看Chart1控件有没有工作区矩形的属性,或者ChartArea的工作区矩形属性,如果有的话,那毫无压力。

回答2:

private void chart1_GetToolTipText(object sender, System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs e)
{
if (e.HitTestResult.ChartElementType == ChartElementType.DataPoint)
{
this.Cursor = Cursors.Cross;
int i = e.HitTestResult.PointIndex;
StringBuilder dpStr =new StringBuilder();
foreach (var item in chart1.Series)
{
DataPoint dp = item.Points[i];
dpStr.Append(item.Name + " X:" + dp.XValue + " Y:" + dp.YValues[0]+"\r\n");
}
e.Text = dpStr.ToString();
}
else
{
this.Cursor = Cursors.Default;
}
}

回答3:

参考
http://blog.csdn.net/chenep/article/details/10052345