How to save app window's size, location and reopen at same. C# code needed.

Posted on 2005-04-06
Medium Priority
Last Modified: 2010-05-18
I want my app to save its window's size and location when it exits and when it reopens, it retrieves these data and opens its window at the same location and with the same size.

Must provide C# code for  VS .NET 2003.
Question by:rj94070
  • 3
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 13724135
Saving and Restoring Location, Size, and Window State of a Form


LVL 14

Accepted Solution

Thandava Vallepalli earned 2000 total points
ID: 13724148
Save and restore Form position and layout with this component


Finally there is no more need to write even a single line of code to persist your window's size, location and state. This article presents a component, which automatically saves these properties to the system registry. In addition, this component allows to save the location and size of any control on a form, including splitters and docked controls.

When the RealPosition component is added to a Form, it gives 2 new boolean properties to visible controls. The first property, RestoreLocation, indicates whether the control's position and size should be persisted. If set to true, the control's position and size are saved when the main form closes. The position and size are restored when the .Load event occurs. The second property, RestoreColumnsWidth, applies only to ListView and inherited controls. It allows saving widths of all columns.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question