Saving SettingsSaving a form's settings
The aim is to get the properties of the Form and the controls in it and save it to a
string called frmstring.'Global Declaration
Posted 14 Jun '10 9:01 PM
pranav952.6K
Reason for my vote of 2
1) Global vars = bad!
2) What are you supposed to do with the string? There's no restore function...
- Johnny J.
15 Jun '10 2:22 AM
Restoring is simple.
Scan the string line by line.
Check if a colon exists in the current line. If it exists, it is a property. So, split it and get the two values. Use SetValue for that particular property.
If there is no colon, then see if a control of that name exists. If it doesn't, skip to the next line
- pranav95
15 Jun '10 11:25 PM
Reason for my vote of 2
you saved the FullName of the type and then right away saved the first property. How are you supposed to differentiate between the end of the type and the beginning of the first property?
And what in the world is with the hyphens? Totally unnecessary.
- William Winner
21 Jun '10 5:05 PM
Here's an alternate: a custom class that is serializable to store all of that in instead of a single string that you'd then have to parse.
Or store it all in an XML file. There are plenty of object-oriented ways to go about this that would be much more readable than just storing it all in a string. And I still want to see your code to get it back. Without being able to do that, being able to store it is pretty useless and only provides an incomplete Tip/Trick
Posted 21 Jun '10 12:16 PM
William Winner10.3K
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
| |||||||||||||||||||||||||||||