Jump to content
Software FX Community

Best way to reset settings that are set in a win forms application?


User (Legacy)

Recommended Posts

I am creating a win forms application where I am using one chart on a form. 

The user has a couple of drop down lists to choose what they would like to

see. After the user chooses and item, I get the data and recreate the

chart. The bummer is I am reusing the same chart to show a line chart or a

bar chart or a pie chart, so I am resetting the data and a lot of properties

like legend boxes showing or not, Axis labels, legends, etc. So far I have

found ClearData that cleans out the data and some labels and I am wondering

if there is a better way to reset some of the values other than just

resetting them to a default each time... is there a good way (other than

creating a new chart) to get a chart back to the state it was in when the

application started?

Link to comment
Share on other sites

This is a question we get often as people expect a Reset method. The problem 

is that it is not clear whether the semantics for this method should be to

reset to our defaults or to the chart as you modified it at design time.

Because of that, we have a Import/Export methods that you can use in these

scenarios. Whenever you have a chart you want to reuse (e.g. at the end of

Form_Load if you want to keep design time settings) you can export the chart

to a memory stream

MemoryStream memStream = new MemoryStream();

chart1.Export(FileFormat.Binary,memStream);

Then when you want to restore that chart you can do

memStream.Position = 0;

chart1.Import(FileFormat.Binary,memStream);

This allows you to have multiple restorable files and/or keep those files in

memory or as temporary files.

--

JC

Software FX Support

"Jason" <jason@cheshire.com> wrote in message

news:VgMdZi7vFHA.3776@webserver3.softwarefx.com...

>I am creating a win forms application where I am using one chart on a form.

>The user has a couple of drop down lists to choose what they would like to

>see. After the user chooses and item, I get the data and recreate the

>chart. The bummer is I am reusing the same chart to show a line chart or a

>bar chart or a pie chart, so I am resetting the data and a lot of

>properties like legend boxes showing or not, Axis labels, legends, etc. So

>far I have found ClearData that cleans out the data and some labels and I

>am wondering if there is a better way to reset some of the values other

>than just resetting them to a default each time... is there a good way

>(other than creating a new chart) to get a chart back to the state it was

>in when the application started?

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...