Save the state of a dynamic windows form application C#

994 views Asked by At

I have built a form where the user can add controls, buttons and more dynamically.

is it possible somehow to save the dynamic controls and load them automatically the next time the user starts the program?

if it is not possible I would like to know if there is a common method or good practice for saving this data to some kind of a config file?

Thanks

1

There are 1 answers

2
Xander On

One way would be to loop through all the controls on the form and save them to Isolated Storage...

https://msdn.microsoft.com/en-us/library/3ak841sy.aspx

https://msdn.microsoft.com/en-us/library/xf96a1wz(v=vs.110).aspx

But it really depends on your use case, do you want to do this automatically and transparent from the user, or do you want to present the user an option to save to a file somewhere?

While it is not specifically for dynamic controls, to give you more ideas see link below on another stackoverflow question :

Best practice to save application settings in a Windows Forms Application