Geeks With Blogs

Blue Probe It’s the parting gift when you host an alien abduction

I started down the path of saving window size settings in the application settings. The fact that I was repeating the same basic info for each form led me to investigate using a custom type to encapsulate this info. The custom type you want to save will have a couple of properties on it, but when you add it to the application settings, you just configure 1 setting. I couldn’t just use the utility to add my type, I had to edit the file. Here’s the steps:

1) Update the settings.settings file

2) Make your custom type [Serializable] – don’t forget to make the class and properties public

I created a custom type to save window settings. With the following signature for the save settings method:

public void SaveSettings(Form aForm)

I was then able to use the following to save my custom type and its properties. Notice that I use the Default[string] method instead of designer created method like Default.MainForm

Properties.Settings.Default[aForm.Name] = this; //Save my custom type


Posted on Tuesday, November 17, 2009 4:59 PM .NET | Back to top

Comments on this post: Winforms application settings using custom types

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Ken Hortsch | Powered by: