May 17th, 2013, 12:27 PM
Saving Controls to File - Help!
In VB 2005, I have a form with a panel control. On right-click of the panel, a context menu displays different types of controls the user can add (at runtime) to the form by clicking the menu items. At runtime, the user adds a variable number of different controls to the form by performing this task mutliple times.
My goal is to have the form remember all of the controls upon form.closing and reload them on form.load, but I'm not sure how to go about translating between control objects and text. Ideally, I'd like to iterate through the panel's controls, and write all properties of each control to a file; but I have no idea how to translate a control object into text (capturing -all- of its properties), or vice versa (creating a control from a comprehensive property list in text/list/etc).
I'd also like to be able to store all of the parent form's controls and their properties, and the form's global variables. Depending on how this can be achieved, I might need to use multiple files for persisting the data (maybe even one per control), but I'm stuck at the translation part.
It's not as easy as grabbing a textbox's .text property, because I also need its .backcolor and everything else. Additionally, some controls have properties that others don't have; so if I wrote a method to iterate through a passed control's .backcolor, .borderstyle, ... , .tag, .text, ... then I'd miss the unique ones (like listbox/combobox .items, checkbox .checked, etc). Is there a way to simply iterate through all properties of a given control and reference the name and value of each?
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!