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.
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
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?
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?
Find my programs on Softpedia
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:
Finally, in the form loading code, add this:
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
Of course, you'll have to replace "CheckBox" with the name of your control and "settingname" with the name of the setting you created.My.Settings.settingname = CheckBox.Checked
My.Settings.Save()
Finally, in the form loading code, add this:
Code: Select all
Again, replace "CheckBox" and "settingname" with the corresponding values.CheckBox.Checked = My.Settings.settingname
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023