<h3>Update: Solved, with code</h3>
<p><a href="https://stackoverflow.com/questions/18585/why-cant-you-bind-the-size-of-a-windows-form-to-applicationsettings#19056">I got it working, see my answer below for the code...</a></p>
<h3>Original Post</h3>
<p>As Tundey pointed out in <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c#18456">his answer</a> to my <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">last question</a>, you can bind nearly everything about a windows forms control to ApplicationSettings pretty effortlessly. So is there really no way to do this with form Size? <a href="http://www.codeproject.com/KB/cs/UserSettings.aspx" rel="nofollow noreferrer">This tutorial</a> says you need to handle Size explicitly so you can save RestoreBounds instead of size if the window is maximized or minimized. However, I hoped I could just use a property like:</p>
<pre><code>public Size RestoreSize
{
    get
    {
        if (this.WindowState == FormWindowState.Normal)
        {
            return this.Size;
        }
        else
        {
            return this.RestoreBounds.Size;
        }
    }
    set
    {
        ...
    }
}
</code></pre>
<p>But I can't see a way to bind this in the designer (Size is notably missing from the PropertyBinding list).</p>

[{'answer_id': 18659, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 1, 'selected': False, 'text': '<p>Well I have had a quick play with this and you are correct, while there is no way to directly <em>bind</em> the size of the form to AppSettings, you can add your own values and change the size on load.</p>\n\n<p>I would perhaps recommend that if this is a common feature, you subclass Form and make it automatically prob the App.Config for the forms size settings.</p>\n\n<p>(Or you could roll your own file.. Get it to query an Xml file "formname.settings.xml" or something? - thinking out loud!)..</p>\n\n<p>Heres what I had (very rough, no error checking etc).</p>\n\n<h2>App.Config</h2>\n\n<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;\n&lt;configuration&gt;\n    &lt;appSettings&gt;\n        &lt;add key ="FormHeight" value="500" /&gt;\n        &lt;add key ="FormWidth" value="200"/&gt;\n    &lt;/appSettings&gt;\n&lt;/configuration&gt;\n</code></pre>\n\n<h2>Form Code</h2>\n\n<pre><code>    private void Form1_Load(object sender, EventArgs e)\n    {\n        string height = ConfigurationManager.AppSettings["FormHeight"];\n        int h = int.Parse(height);\n        string width = ConfigurationManager.AppSettings["FormWidth"];\n        int w = int.Parse(width);\n        this.Size = new Size(h, w);\n    }\n</code></pre>\n'}, {'answer_id': 18674, 'author': 'Martin', 'author_id': 770, 'author_profile': 'https://Stackoverflow.com/users/770', 'pm_score': 2, 'selected': False, 'text': '<p>One of the reason I imagine size binding is not allowed is because the screen may change between sessions.</p>\n\n<p>Loading the size back when the resolution has reduced could result in the title bar being beyond the limits of the screen.</p>\n\n<p>You also need to be wary of multiple monitor setups, where monitors may no longer be available when you app next runs.</p>\n'}, {'answer_id': 18697, 'author': 'Tundey', 'author_id': 1453, 'author_profile': 'https://Stackoverflow.com/users/1453', 'pm_score': 1, 'selected': False, 'text': "<p>I agree with Rob Cooper's answer. But I think Martin makes a very good point. Nothing like having users open your application and the app is off-screen! </p>\n\n<p>So in reality, you'll want to combine both answers and bear in mind the current screen dimensions before setting your form's size.</p>\n"}, {'answer_id': 19056, 'author': 'Brian Jorgensen', 'author_id': 229, 'author_profile': 'https://Stackoverflow.com/users/229', 'pm_score': 5, 'selected': True, 'text': '<p>I finally came up with a Form subclass that solves this, once and for all. To use it:</p>\n\n<ol>\n<li>Inherit from RestorableForm instead of Form.</li>\n<li>Add a binding in (ApplicationSettings) -> (PropertyBinding) to WindowRestoreState.</li>\n<li>Call Properties.Settings.Default.Save() when the window is about to close.</li>\n</ol>\n\n<p>Now window position and state will be remembered between sessions. Following the suggestions from other posters below, I included a function ConstrainToScreen that makes sure the window fits nicely on the available displays when restoring itself.</p>\n\n<h3>Code</h3>\n\n<pre><code>// Consider this code public domain. If you want, you can even tell\n// your boss, attractive women, or the other guy in your cube that\n// you wrote it. Enjoy!\n\nusing System;\nusing System.Windows.Forms;\nusing System.ComponentModel;\nusing System.Drawing;\n\nnamespace Utilities\n{\n    public class RestorableForm : Form, INotifyPropertyChanged\n    {\n        // We invoke this event when the binding needs to be updated.\n        public event PropertyChangedEventHandler PropertyChanged;\n\n        // This stores the last window position and state\n        private WindowRestoreStateInfo windowRestoreState;\n\n        // Now we define the property that we will bind to our settings.\n        [Browsable(false)]        // Don\'t show it in the Properties list\n        [SettingsBindable(true)]  // But do enable binding to settings\n        public WindowRestoreStateInfo WindowRestoreState\n        {\n            get { return windowRestoreState; }\n            set\n            {\n                windowRestoreState = value;\n                if (PropertyChanged != null)\n                {\n                    // If anybody\'s listening, let them know the\n                    // binding needs to be updated:\n                    PropertyChanged(this,\n                        new PropertyChangedEventArgs("WindowRestoreState"));\n                }\n            }\n        }\n\n        protected override void OnClosing(CancelEventArgs e)\n        {\n            WindowRestoreState = new WindowRestoreStateInfo();\n            WindowRestoreState.Bounds\n                = WindowState == FormWindowState.Normal ?\n                  Bounds : RestoreBounds;\n            WindowRestoreState.WindowState = WindowState;\n\n            base.OnClosing(e);\n        }\n\n        protected override void OnLoad(EventArgs e)\n        {\n            base.OnLoad(e);\n\n            if (WindowRestoreState != null)\n            {\n                Bounds = ConstrainToScreen(WindowRestoreState.Bounds);\n                WindowState = WindowRestoreState.WindowState;\n            }\n        }\n\n        // This helper class stores both position and state.\n        // That way, we only have to set one binding.\n        public class WindowRestoreStateInfo\n        {\n            Rectangle bounds;\n            public Rectangle Bounds\n            {\n                get { return bounds; }\n                set { bounds = value; }\n            }\n\n            FormWindowState windowState;\n            public FormWindowState WindowState\n            {\n                get { return windowState; }\n                set { windowState = value; }\n            }\n        }\n\n        private Rectangle ConstrainToScreen(Rectangle bounds)\n        {\n            Screen screen = Screen.FromRectangle(WindowRestoreState.Bounds);\n            Rectangle workingArea = screen.WorkingArea;\n\n            int width = Math.Min(bounds.Width, workingArea.Width);\n            int height = Math.Min(bounds.Height, workingArea.Height);\n\n            // mmm....minimax\n            int left = Math.Min(workingArea.Right - width,\n                                Math.Max(bounds.Left, workingArea.Left));\n            int top = Math.Min(workingArea.Bottom - height,\n                                Math.Max(bounds.Top, workingArea.Top));\n\n            return new Rectangle(left, top, width, height);\n        }\n    }\n}\n</code></pre>\n\n<h3>Settings Bindings References</h3>\n\n<ul>\n<li><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.settingsbindableattribute.aspx" rel="noreferrer">SettingsBindableAttribute</a></li>\n<li><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" rel="noreferrer">INotifyPropertyChanged</a></li>\n</ul>\n'}, {'answer_id': 260707, 'author': 'HTTP 410', 'author_id': 13118, 'author_profile': 'https://Stackoverflow.com/users/13118', 'pm_score': 3, 'selected': False, 'text': '<p>The reason why the Form.Size property is not available in the settings binding UI is because this property is marked <strong>DesignerSerializationVisibility.Hidden</strong>. This means that the designer doesn\'t know how to serialise it, let alone generate a data binding for it. Instead the <strong>Form.ClientSize</strong> property is the one that gets serialised.</p>\n\n<p>If you try and get clever by binding <strong>Location</strong> and <strong>ClientSize</strong>, you\'ll see another problem. When you try to resize your form from the left or top edge, you\'ll see weird behaviour. This is apparently related to the way that two-way data binding works in the context of property sets that mutually affect each other. Both <strong>Location</strong> and <strong>ClientSize</strong> eventually call into a common method, <strong>SetBoundsCore()</strong>. </p>\n\n<p>Also, data binding to properties like <strong>Location</strong> and <strong>Size</strong> is just not efficient. Each time the user moves or resizes the form, Windows sends hundreds of messages to the form, causing the  data binding logic to do a lot of processing, when all you really want is to store the last position and size before the form is closed.</p>\n\n<p>This is a very simplified version of what I do:</p>\n\n<pre><code>private void MyForm_FormClosing(object sender, FormClosingEventArgs e)\n{\n    Properties.Settings.Default.MyState = this.WindowState;\n    if (this.WindowState == FormWindowState.Normal)\n    {\n       Properties.Settings.Default.MySize = this.Size;\n       Properties.Settings.Default.MyLoc = this.Location;\n    }\n    else\n    {\n       Properties.Settings.Default.MySize = this.RestoreBounds.Size;\n       Properties.Settings.Default.MyLoc = this.RestoreBounds.Location;\n    }\n    Properties.Settings.Default.Save();\n}\n\nprivate void MyForm_Load(object sender, EventArgs e)\n{\n    this.Size = Properties.Settings.Default.MySize;\n    this.Location = Properties.Settings.Default.MyLoc;\n    this.WindowState = Properties.Settings.Default.MyState;\n} \n</code></pre>\n\n<p>Why is this a very simplified version? Because doing this properly is <a href="http://miksovsky.blogs.com/flowstate/2005/10/the_fractal_nat.html" rel="noreferrer">a lot trickier</a> than it looks :-)</p>\n'}]
['https://Stackoverflow.com/questions/18585', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/229/']