I've been looking for answers to this problem for awhile, and none of what I find seems to work. I have a program that creates a database, and a form based on that database, where the form fields are movable (the user can drag them around in the form) in Panel1 of a split contianer, and the other panel contains a datagridview. That all works fine for now. What I am having problems with is persistence, when I publish the application and get everything set up, then close it and open it again, everythign is gone. Now, I am assuming this is because the app.config file does not have variables to store all of these settings in because I don't know how many or what the user will be creating.

My best guess is to edit the app.config file as the form is created to create a variable for each field in it. I will still be working on this problem going in that direction, but if anyone has any better suggestions, or if you know how I can do this, I would appreciate that.

If the fields in the database table are static, you can assign a number to each and use a single config variable to hold a comma-delimited list of fields in the specified order. I've done that quite easily in the configuration section of programs. The same process could be used even if there is nothing static about the data. A comma-delimited list of field names works just as well.

If this is not what you want then use one variable as a counter and create sequential variables for the fields, i.e., fldCtr = 3, fld1 = Name, fld2=Address, fld3 = SalesAmt. You read the fldCtr and use it as a loop counter to pull the other values.

Comments
a point in the right direction for me

I think I will create another data table in the database for the field information, thank you

This article has been dead for over six months. Start a new discussion instead.