Click here to Skip to main content
15,888,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..How can i refresh the graph automatically when i open a second file to be processed?I open a text file and got my graph after processed from the data file.But when I open a second file to be processed,the graph overlap each other and the graph become weird.How can I refresh it first when open a new file to be processed,so that only the second data graph is shown?Thanks.
Posted
Updated 26-Jul-12 17:43pm
v2

1 solution

Difficult to say without code, but if you are creating the entire graph dynamically, then you would need to dispose of the original graph first OR edit the original graph ie:
C#
Chart tmpChart = new Chart();
tmpChart.Width = 100;
tmpChart.Height = 100;
tmpChart.Location = new Point(100, 100);

this.Controls.Add(tmpChart);

This code will add chart on top of chart each time I use it to add a chart.
However:
C#
Chart tmpChart;
tmpChart = (Chart)this.Controls["TempChart"];
if (tmpChart == null) { tmpChart = new Chart(); }
tmpChart.Width = 100;
tmpChart.Height = 100;
tmpChart.Location = new Point(100, 100);
tmpChart.Name = "TempChart";

this.Controls.Add(tmpChart);

This code will replace the information on the same chart with the new information. This sort of method works for basically all controls in c#. hope this is somewhere near what you are asking.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900