You have several options for saving the entered settings - in the configuration file or in the registry, possibly in the database (maybe even in the "cloud", but I wonβt go there).
Before saving the settings, the user must perform a certain action (for example, click the "Apply" button) - you should not just save the settings when the user closes the form, as this is ultimately not a very good UX.
How you save the settings is completely up to you - you can save them to a style configuration file with a direct name / value, you can use XML in the configuration file or save them as keys and values ββto a known place in the registry (or you can save name pairs / value in the database table).
When your application starts next time, one of the launch tasks may be to check a known location (whether it is a registry or a configuration file) for parameters, and then load them into the settings class. Make sure you have logical defaults for each parameter, if it has never been set or for some reason you cannot read it. The settings class can then be transferred to each form so that it applies any settings or it can be a static class (globally visible class of one instance) so that it can be easily read from anywhere in the application.
Edit: after reading your comment on another answer, here is another option, a bit more advanced. Use the settings class mentioned earlier, but also use the binding - you can bind your settings object directly to your form, so any entered values ββwill be updated directly in the settings object without the need to write code for this (provided that you use two methods of binding) . Streaming can be achieved by serializing the settings object to a file (or database), I suggest you look at the XmlSerializer .
slugster
source share