CheckBox State MySettings

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

CheckBox State MySettings
Mark
Hello,

Was wondering if anyone can help me please was wondering how do i go about saving the state of my checkbox if its true or false and then load that when the application runs again?
http://www.mbappz.com
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: CheckBox State MySettings
Shim
Find my programs on Softpedia
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: CheckBox State MySettings
comathi
If you absolutely want to use My.Settings, here's what you could do:

First of all, create a new setting (I'm assuming you know how to do this already). Set the setting type to "Boolean" and the default value to whatever the default check state of your checkbox is. (ie, if your checkbox is unchecked by default, set it to False).

In your CheckBox.CheckedChanged event, you'll want to put the following code:
Code: Select all
My.Settings.settingname = CheckBox.Checked
My.Settings.Save()
Of course, you'll have to replace "CheckBox" with the name of your control and "settingname" with the name of the setting you created.

Finally, in the form loading code, add this:
Code: Select all
CheckBox.Checked = My.Settings.settingname
Again, replace "CheckBox" and "settingname" with the corresponding values.
3 posts Page 1 of 1
Return to “Tutorial Requests”