Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form has minimum size after restoring from minimize state

I Added ClientSize to Application Settings and DataBindings in Properties window, in order to save size of the form after it was closed. And that worked. But when I minimize form and then activate it back, it has minimum size . Is it a bug or I'm doing something wrong

  1. Create New Project (WindowForm Application)
  2. Open Properties Window form Form1
  3. In Application Settings choose PropertyBinding
  4. Add Binding for Location and ClientSize
  5. Run
  6. Maximize and then Restore
like image 471
Stecya Avatar asked Feb 23 '11 09:02

Stecya


1 Answers

I found answer in this topic. So to save size and location without side effects , need to remove binding and save application settings by hand

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
   Properties.Settings.Default.Size = this.Size;
   Properties.Settings.Default.Location = this.Location;
   Properties.Settings.Default.Save();
}

private void Form1_Load(object sender, EventArgs e)
{
   this.Size = Properties.Settings.Default.Size;
   this.Location = Properties.Settings.Default.Location;
}
like image 64
Stecya Avatar answered Oct 04 '22 07:10

Stecya