I have attached a Visual Studio 2005 project (as a zip file) that shows how to save your values from the form to a text file, and as an added bonus, a way of bringing those values back from a text file.
It uses a couple recursive methods .
There are certainly ways to streamline it. You could even use reflection to help save every property and event declaration to an XML file, and regenerate the form to a specific state on demand.
If you want to get real creative, you could actually Create a new blank form and populate it from the XML file (except for the events.). This demo project does nothing like that.
All the demo project does is write a simple text file with the Component Name=value combo.
I was read your poost and I was really great, but my question is how can I write just the controls on the form I wan , I have 40 checkboxes and I want to to write just 10 of them to txt file,,,,could you please tell me how ???
Do you know exactly which ones you want to write to Text ?
Do you want to use their Names ? (example checkbox1, checkbox23)
Instead of names, do you want to use a Tag value to determine which ones are to be written to Text ? (example all checkboxes with a Tag = "Save this checkbox to text"; ?
You have some checkbox components you want to write to Text... I assume that you already know which ones you want to use. So you now just need to identify which ones you want written.
Let me know how you want to proceed. If you want, you can send your project to me (zipped) at email@example.com and a list of the checkboxes you want saved, and I can show you how in your own code.