强制重新绘制Windows窗体DataVisualization图表

时间:2014-03-04 08:54:32

标签: windows forms charts

当您使用DataVisualization Chart对象并向其添加点时,图表会自动更新,但是当您更改点时,图表不会更新。例如:

System.Windows.Forms.DataVisualization.Charting.Chart myChart;

// When you add points, the chart is automatically redrawn.
myChart.Series[0].Points.AddXY(0,0);
myChart.Series[0].Points.AddXY(1,1);
myChart.Series[0].Points.AddXY(2,0);

// When I change the value of points, the chart is not automatically redrawn.
myChart.Series[0].Points[0].SetValueXY(0,1);

如何强制重绘图表?像myChart.Update()之类的东西。作为一种解决方法,我正在删除最后一点,并在每次更新时重新添加它以强制重绘,但我想要更优雅的东西。:

// Re-add last point to force redraw.
myChart.Series[0].Points.RemoveAt(2);
myChart.Series[0].Points.AddXY(2,0);

0 个答案:

没有答案