Search code examples
c#.netwinformswindow

.NET / Windows Forms: remember windows size and location


I have a Windows Forms application with a normal window. Now when I close the application and restart it, I want that the main window appears at the same location on my screen with the same size of the moment when it was closed.

Is there an easy way in Windows Forms to remember the screen location and window size (and if possible the window state) or does everything have to be done by hand?


Solution

  • You'll need to save the window location and size in your application settings. Here's a good C# article to show you how.

    EDIT

    You can save pretty much anything you want in the application settings. In the Type column of the settings grid you can browse to any .NET type. WindowState is in System.Windows.Forms and is listed as FormWindowState. There's also a property for FormStartPosition.