Application Settings and Form Location & Size

  • Thread starter Thread starter Roger Down
  • Start date Start date
R

Roger Down

I'm trying to use Application Settings with From Location & Size. I have
created the property binding from the Designer in Visual Studio.

ClientSize = MainFormClientSize
Location = MainFormLocation

I also have the following code:

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.MainFormClientSize = this.ClientSize;
Properties.Settings.Default.MainFormLocation = this.Location;
Properties.Settings.Default.Save();
}

The code seems to work fine. I can start the application, change the size
and location and close the application. And the next time I open the
application, the size and location is correct from the last time the
application was closed.

But something strange happens if I try to minimize and restore the
application. If I already have a size and location saved, do a minimize and
restore, then the initial default value are set on the form.

Do I need additional code to addresse minimize / restore scenarioes ?

Best of regards... :-)
 
Roger Down said:
I'm trying to use Application Settings with From Location & Size. I have
created the property binding from the Designer in Visual Studio.

ClientSize = MainFormClientSize
Location = MainFormLocation

I also have the following code:

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.MainFormClientSize = this.ClientSize;
Properties.Settings.Default.MainFormLocation = this.Location;
Properties.Settings.Default.Save();
}

The code seems to work fine. I can start the application, change the size
and location and close the application. And the next time I open the
application, the size and location is correct from the last time the
application was closed.

You may want to take a look at the form's 'RestoreBounds' property.
 
Back
Top