Groups | Blog | Home
all groups > dotnet windows forms databinding > july 2007 >

dotnet windows forms databinding : How to write a config setting at FormClosing


Paul
7/15/2007 6:45:43 PM
I have bound the form's Location property to a userSettings setting
"WindowLocation" using the configuration settings dialogs in vs2005. I
can't within a few minutes figure out how to write out the setting on
FormClosing event. I find the few docs on this totally obtuse. Can you
Paul
7/15/2007 10:52:58 PM
[quoted text, click to view]

For the benefit of future googlers.

In vs2005 define 2 user settings: WindowLocation and WindowSize.

Form OnLoad:

this.Location = Properties.Settings.Default.WindowLocation;
this.Size = Properties.Settings.Default.WindowSize;

Form OnClosing:

Properties.Settings.Default.WindowLocation = this.Location;
Properties.Settings.Default.WindowSize = this.Size;
Properties.Settings.Default.Save();

The file for persistence is "user.config" in the user's ..\Local
Settings\Application Data\CompanyName\ProgramNameHash folder.
AddThis Social Bookmark Button