Reputation: 21190
I am allowing the users to be able to make their own font choices for a listview. What would you consider the best approach for this. Should I save it to the registry or to a file in the application folder, and what properties should be saved to make sure that the font is redisplayed properly when the application is restarted?
Thanks for your suggestions.
EDIT:
Thanks for all the answers.In answering one of your questions - The machine will not be used for multiple users.
what should I save inorder to recreate the settings.
if I save it to a delimited string can the font class parse this? "Microsoft Sans Serif, 8.25pt, style=Bold"
Upvotes: 6
Views: 10399
Reputation: 124034
Regarding where/how to save application settings see this answer
You can save your font as a string and load it later using following code:
Font font1 = new Font("Arial", 12, FontStyle.Italic);
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
// Saving Font object as a string
string fontString = converter.ConvertToString(font1);
// Load an instance of Font from a string
Font font = (Font)converter.ConvertFromString(fontString);
Upvotes: 16
Reputation: 19479
You could also use isolated storage.
Really, you need to know if the application is ever shared across user profiles on the same machine. If not, you can get away with storing it in a config file. If it is, then you can use the registry (maintainable), or isolated storage (secure).
EDIT: After your last update, you can save typed values in the app config. For example, If I want to save a color, I can save the value as a type System.Color, and the runtime will parse it for me. Check this article for more info and examples.
Upvotes: 0
Reputation: 2102
You should probably use the configuration file (most probably user settings section)... but it's best to avoid saving stuff to the application folder...unless you meant Application Data folder.
Upvotes: 0