Save and restore Form position and DataGridView's configuration
My Application need to save and restore components when restart next time. Such as:
-Change size and position of the form itself.
-Change width, order of columns of DataGridView's columns.
I want to save information configure into configuration file.
Everybody have ideas, please show me way to do it or give some solution examples.
I'm using VS.NET 2005, C#
Thanks
BeckKhiem.
Hi,
As you said you could try saving the locations and other properties to a .ini file. You could simply use the basic textfile classes available on .net to create the .ini file. You could save it on your unload and read it on your load event. If you want it to be hidden to the users eye. THen you could store it in the registry....
cheers,
Paul June A. Domag
Thanks for your help.
Because my application need to save and restore width, order of columns in DataGridView so i created a array
to save this information. But client configuration just support single value, therefore i'm very difficult to solve my solution.
Please tell me more detail about my solution.
Thanks.
I took a cursory glance at this issue this morning and I believe a simple example is not possible and a good, useful example goes beyond the scope of these forums. This is my way of saying that I couldn't find enough info on the web to put it all together. Perhaps when VS.NET 2005 is released the documentation will provide a more complete example of how to persist user preferences for complex objects like this.
Use a dataset. It should have 3 columns, Form, Field, and value. When your application starts up, it should load the dataset into a shared object. Then in your form's show event, it reads the appropriate values. When it closes, it updates the appropriate values back to the dataset. Finally when the app closes, it writes the dataset to disk.
I use a variant of this using a database in one of my apps today. All of my show, close code is in a base class form, so all of its children get the behavior for "free."
(I'm borrowing this behavior from code that an ex-coworker had in a PowerBuilder app a decade ago.)
Mike