473,408 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Save Settings

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?
Dec 25 '05 #1
6 5094

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

On Sun, 25 Dec 2005 17:43:27 +0700, "Laserson" <la******@inbox.ru>
wrote:
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?


Dec 25 '05 #2

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...a-04c861fac4a5

regards

Michel Posseth [MCP]

"Laserson" <la******@inbox.ru> wrote in message
news:OM*************@TK2MSFTNGP15.phx.gbl...
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?

Dec 25 '05 #3
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.
--
Dennis in Houston
"Laserson" wrote:
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?

Dec 25 '05 #4
"Laserson" <la******@inbox.ru> schrieb:
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?


..NET 1.0/1.1:

Storing and loading user preferences
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=userpreferences&lang=en>

..NET 2.0:

'My.Settings'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 25 '05 #5
ok...i couldn't understand anything...Anybody write me a small sample right
here!

"Laserson" <la******@inbox.ru> wrote in message
news:OM*************@TK2MSFTNGP15.phx.gbl...
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?

Dec 26 '05 #6
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.
--
Dennis in Houston
"Laserson" wrote:
ok...i couldn't understand anything...Anybody write me a small sample right
here!

"Laserson" <la******@inbox.ru> wrote in message
news:OM*************@TK2MSFTNGP15.phx.gbl...
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?


Dec 26 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sam Carleton | last post by:
It is my understanding that in .Net the registry is not the prefered place to save application settings. What has Microsoft put in place to replace it? I thought it was the .config file, but I...
1
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of...
3
by: Boris Sargos | last post by:
Hi, I don't maange to save the user settings in my application. I created a settings file named MySettings.settings, that contains the property "BackupFolder" (string typed), in User mode. The...
3
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
4
by: keithb | last post by:
How can an application change settings in the web.config file? I need to allow users to configure SMTP email settings with functionality similar to that provided developers by the ASP.NET Web Site...
0
by: ssg31415926 | last post by:
I've been trying to save a hashtable in an Application Settings file. I need to save settings for each tabPage on a form. Trouble is, the number of tabPages is determined at runtime, so I can't...
2
by: John | last post by:
I have a Win app in C#. I want to save the data the user enterere into textboxes and the selections the user made to comboboxes when the user close the app. So next time when the user launches the...
4
by: Richard Lewis Haggard | last post by:
I have an application that can't use the registry to save various user options and application settings. My first thought was to simply use an application configuration file but this approach seems...
0
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hello, I have a .net 2.0 application using a 'Settings.settings' configuration file to store application settings. The settings are modified at runtime and stored when the user exits the...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.