[Help] My.Settings to save checkboxes [solved]

Posts 1–8 of 8 · Page 1 of 1
[Help] My.Settings to save checkboxes [solved]
Ok, so im trying to save 2 check boxes.

On click/formclosing

Code:
If CheckBox1.Checked = True Then
            My.Settings.check1 = CheckBox1.Checked = True
        Else
            My.Settings.check1 = CheckBox1.Checked = False
        End If
        If CheckBox2.Checked = True Then
            My.Settings.check2 = CheckBox2.Checked = True
        Else
            My.Settings.check2 = CheckBox2.Checked = False
        End If
        My.Settings.Save()
On load

Code:
        CheckBox1.Checked = My.Settings.check1
        CheckBox2.Checked = My.Settings.check2
When it loads, both of them are always checked...
Code:
My.Settings.check1 = CheckBox1.Checked = True
Whats that? O.ô 2x = in 1 line?
Quote Originally Posted by edub18 View Post
Code:
My.Settings.check1 = CheckBox1.Checked = True
Whats that? O.ô 2x = in 1 line?
What do you mean? One is False, One is True
Put on Form Close event
Code:
If CheckBox1.Checked = True Then
My.Settings.check1 = True
Else
My.Settings.check1 = False
End If
''' this was for checkbox 1 now for checkbox2
If CheckBox2.Checked = True Then
My.Settings.check2 = True
Else
My.Settings.check2 = False
End If
should work make sure u maked the settings type to boolean and the value set to false
Or just put on the CheckChanged event of each CheckBox:

[highlight=vb.net]
My.Settings.check1 = CheckBox1.Checked
My.Settings.check2 = CheckBox2.Checked
My.Settings.Save()
My.Settings.Reload()
[/highlight]

Then on the form load do what you're already doing.
Quote Originally Posted by Jason View Post
Or just put on the CheckChanged event of each CheckBox:

[highlight=vb.net]
My.Settings.check1 = CheckBox1.Checked
My.Settings.check2 = CheckBox2.Checked
My.Settings.Save()
My.Settings.Reload()
[/highlight]

Then on the form load do what you're already doing.
Yeah, thats what I figured out... I didnt use Reload though
Quote Originally Posted by Cryptonic View Post


Yeah, thats what I figured out... I didnt use Reload though
Reload isn't actually necessary, it just resets all settings to their last-saved state. It'd probably work without them.
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us