How do I go about saving dynamically added WinForms controls?
My application should be able to do this for the following: TabPage
, GroupBox
, RadioButton
, and CheckBox
. The RadioButton
and CheckBox
both correspond to a block of text that will be outputted when selected. I understand the process would consist of creating the controls first and storing them, but I am unsure whether what I have found so far (listed below) are the most apt ways to go about doing so.
Creating the Controls
The topic I linked suggested the use of objects that inherit from specific controls. This means I should just instantiate such objects as needed and assign the dynamic values accordingly. It appears to be the easiest way to do this step unless someone suggests otherwise.
Storing Controls
For this part, I was thinking of:
A. Database
My application uses SQLite to save the text and the control properties could also be saved into and retrieved from it via a method from the aforementioned classes.
B. XML
Perhaps a configuration file that I will make myself to write and read from? Tutorials seem aplenty on how to process XML, which makes it doable for me. I am unsure, however, whether storing lengthy text is advisable here, and likewise for what follows.
C. Serialization
Researching got me 3 results--JSON, XmlSerializer
, and BinaryFormatter
--all of which I have not had experience with as far C# is concerned. There seems to be difficulty in deserializing controls, and each control needs to be serialized differently.
D. UserSetting
This appears to be similar to XML, only that it uses StringCollection
or Settings.setting instead.
Suggestions, recommendations, or corrections anyone?