How to Store state of controls on a Form?

C

CodeMonkey

Hi All,
I will be writing a Windows Forms application with potentially a large
number of forms, which each contain text fields, dropdowns and so on.
The user will want to be able to open one form, add values to the text
controls, change the dropdowns and so on and then close the form. The
user will repeat the process for other forms, but may want to go back
to earlier forms and make further changes. What are my options for
saving the state of the controls so that when the user goes back to
each form they are as they left them when the form closed?

Any sample code, links would be helpful.
All help greatly appreciated.

Thanks
Andrew.
 
C

Chris Dunaway

The best solution is to create a class that holds all the data that
needs to be displayed. When a form is opened, it should populate its
fields with the values of the properties of the class.

The form should not be used to store the data. It's sole purpose
should be to display the data. The data should be stored in a class or
other storage medium such as a file.

Look for the Model View Controller design pattern and it will give you
further details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top