VB.NET Saving object properties
-
I was wondering if there is an easy way to save the properties of the objects such as Checkboxes, Textboxes, comboboxes, etc. in VB.NET that doesn't use the registry. I am looking for a way to write it to a file, then on load read from that file and change the settings back to what they were when it was saved. I have been searching for quite a while how to do this, but to no avail. I was originally thinking that I could write the information to a text file then set the information in that text file to a string and run that string as code however, I couldn't find a way to get the string to run as executable code. If you have any ideas for either of these please tell me. Thanks.
-
I was wondering if there is an easy way to save the properties of the objects such as Checkboxes, Textboxes, comboboxes, etc. in VB.NET that doesn't use the registry. I am looking for a way to write it to a file, then on load read from that file and change the settings back to what they were when it was saved. I have been searching for quite a while how to do this, but to no avail. I was originally thinking that I could write the information to a text file then set the information in that text file to a string and run that string as code however, I couldn't find a way to get the string to run as executable code. If you have any ideas for either of these please tell me. Thanks.
Running a string as code is both easy, widely documented, and a terrible way to do what you're after. One possible way is to use reflection to get the properties of each control and store them, then use reflection to set the same properties on the same named controls. An easier way that needs more work as your form changes, is to store specific properties in a format you define and read those to place them back on the controls.
Christian Graus Driven to the arms of OSX by Vista.
-
I was wondering if there is an easy way to save the properties of the objects such as Checkboxes, Textboxes, comboboxes, etc. in VB.NET that doesn't use the registry. I am looking for a way to write it to a file, then on load read from that file and change the settings back to what they were when it was saved. I have been searching for quite a while how to do this, but to no avail. I was originally thinking that I could write the information to a text file then set the information in that text file to a string and run that string as code however, I couldn't find a way to get the string to run as executable code. If you have any ideas for either of these please tell me. Thanks.
Serialize it.
-
I was wondering if there is an easy way to save the properties of the objects such as Checkboxes, Textboxes, comboboxes, etc. in VB.NET that doesn't use the registry. I am looking for a way to write it to a file, then on load read from that file and change the settings back to what they were when it was saved. I have been searching for quite a while how to do this, but to no avail. I was originally thinking that I could write the information to a text file then set the information in that text file to a string and run that string as code however, I couldn't find a way to get the string to run as executable code. If you have any ideas for either of these please tell me. Thanks.
I use XML to do the form state/size[^]. No reason why you can't use it for controls.
Never underestimate the power of human stupidity RAH
-
I was wondering if there is an easy way to save the properties of the objects such as Checkboxes, Textboxes, comboboxes, etc. in VB.NET that doesn't use the registry. I am looking for a way to write it to a file, then on load read from that file and change the settings back to what they were when it was saved. I have been searching for quite a while how to do this, but to no avail. I was originally thinking that I could write the information to a text file then set the information in that text file to a string and run that string as code however, I couldn't find a way to get the string to run as executable code. If you have any ideas for either of these please tell me. Thanks.
You can use Application Settings to save properties of the objects like Textbox.Text or any other...