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.

[2168 byte] By [BeckKhiem] at [2007-12-17]
# 1
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

PaulDomag at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
The .NET Framework 2.0 provides what you are looking for:

Check out the Windows Forms section of this link:
http://lab.msdn.microsoft.com/vs2005/downloads/101samples/default.aspx

Try this link as well:
http://msdn2.microsoft.com/en-us/library/k4s6c3a0

CRitchie at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
Thanks for your help.

Because my application need to save and restore width, order of columns in DataGridView so i created a arrayNoNo 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.

BeckKhiem at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
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.
CRitchie at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
I'm doing the same thing and using the simple

IsolatedStorageFile

class. It's a hidden file saved for each user on each machine, it's a simple xml file so I think an array can easely be saved.

ThE_lOtUs at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
Dear ThE_lOtUs,
It is a first time i have solved this solution. If you don't mind please give me your sample code. I have solved this problem for a long time, but i can't. So i post this topic in forum and hope eveybody discuss so that i can get some useful in formation.

Thanks for your help

BeckKhiem at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7
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

mpswaim at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8

I think that all these replies are right. The right one to me is the dataset option and store the settings in the database.
Ive seen that Microsoft Access stores these settings this way. the data is located in the hidden tables of each mdbs. it is a little difficult to me to read the way its stored but i think it can be done.

MacKraken at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...