سؤال

When you use a DataVisualization Chart object and you add points to it, the graph is automatically updated but when you change the points the chart is not updated. For example:

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);

How can I force a redraw of the chart? Something like myChart.Update() or something. As a workaround I'm deleting the last point and re-adding it at each update to force a redraw, but I would like something a little bit more elegant.:

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

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top