Search code examples
c#winformscheckboxstateapplication-settings

How to save state of checkbox, textbox and ... after closing a program in c#


In my C# program that is made with Visual Studio 2010 and uses WinForms, I would like the program to save state of some checkboxes and textboxes so the next time program will be loaded they are checked or unchecked as theire last run's state. Also same with strings inside textboxes and etc...

What will be the proper way to achieve this? Is there a built in stuff in .NET? Any tips and code snippets would be appriciated!

Thanks


Solution

  • You'd probably want to look at reading the relevant values from your UI during the FormClosing event, and then saving them into User Settings.

    Have a look at: http://codehill.com/2009/01/saving-user-and-application-settings-in-winforms/