Save Settings

  • Thread starter Thread starter Laserson
  • Start date Start date
L

Laserson

Hi! I have one question about SaveSetting() function. I have one checkbox
and i want to save it's state on form closing and then restore it on form
loading. How can i make it?
 
Check the page "Managing Application Settings":
http://msdn2.microsoft.com/en-us/library/c9db58th.aspx

More specifically, "How to: Add or Remove Application Settings":
http://msdn2.microsoft.com/en-us/library/25zf0ze8.aspx

Or you can roll your own, such as is done here:
http://www.codeproject.com/vb/net/ConfigOpt.asp

and in many other examples you can find on the web.

You will probably want to save the setting in the _FormClosing
event (while the checkbox control is still alive and well).

Make sure you restore the value in the checkbox after the
checkbox has been created and initialized. Also, make sure
that setting the value through code does not trigger any unwanted
side-effects, i.e. event handlers for the checkbox should know
that the value has been set through code instead of as the result
of a user action.

As for using SaveSetting: Are you sure you want to do this?
SaveSetting will store the value in the Registry at
HKEY_CURRENT_USER\Software\VB and VBA Program Settings.
It is a leftover from the bad old "classic" VB days and I do not
think it should be used in any new .Net code, except if compatibility
with old applications is needed.

/JB
 
you can parse the values stored in the config file
boolean.parse(stringvalue) where stringvalue is the value retrived in the
config file


you might also investigate this handy class ( i use it in my projects )
wich will save you a lot of coding as it can point to anny location and anny
valid XML config file where it will optionaly create the values that are not
yet there ( with your default values )

http://www.vb2themax.com/ShowContent.aspx?ID=5d8114d9-0e1b-457a-a66a-04c861fac4a5

regards

Michel Posseth [MCP]
 
Just a comment...I have found that creating a class (call it "StartSettings"
or something like that) that can be serialized and use serialization to save
and retrieve the class properties in a .dat file. I have found this is the
most flexible way to do this and doesn't require a lot of work nor alter the
user's registry.
 
ok...i couldn't understand anything...Anybody write me a small sample right
here!
 
There are lots of examples of serailization and deserialization of a class.
Try writing the code and running. If you stil have problems, post your code
and someone will help identify the errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top