[RESOLVED] Can not saving app's settings
Hi all,
I've a project called G.S.S. There's a 2 forms in the G.S.S and a checkbox on the form2. I added these codes:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form2.CheckBox4.Checked = My.Settings.chk
End Sub
AND
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
My.Settings.chk = Form2.CheckBox4.Checked
End Sub
But it's not working :( :confused:
Then I created an another example project to try these on, added 2 forms, a checkbox on form2 and wrote same codes. I wondered when I run the app because it's running perfect. It saves the settings :confused:
So what's wrong with my G.S.S project? :confused:
(Sorry because of my terrible English :( )
Re: Can not saving app's settings
Quote:
Originally Posted by
canavaroski90
Hi all,
I've a project called G.S.S. There's a 2 forms in the G.S.S and a checkbox on the form2. I added these codes:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form2.CheckBox4.Checked = My.Settings.chk
End Sub
AND
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
My.Settings.chk = Form2.CheckBox4.Checked
End Sub
But it's not working :( :confused:
Then I created an another example project to try these on, added 2 forms, a checkbox on form2 and wrote same codes. I wondered when I run the app because it's running perfect. It saves the settings :confused:
So what's wrong with my G.S.S project? :confused:
(Sorry because of my terrible English :( )
With checkboxes why don't you just bind the 'checked' property of the control to a my.settings value?
I'm having a similar problem to you with radio buttons (because they mess up if you bind them).. but my bound checkboxes save fine.
Re: Can not saving app's settings
Check that in your project properties you have the box ticked that says "Save Settings On Exit" or something like that.
If you dont want that setting turned on for whatever reason then you can always just manually call My.Settings.Save()
Re: Can not saving app's settings
To "chris128"; I tried this method but it's stilll not working.
And 4xzer0, can you explain your suggestion in more detailed way?
Re: Can not saving app's settings
Did you check that the option named "Save My.Settings on Shutdown" is enabled in your project as I mentioned?
Also, your Chk setting is of type Boolean isnt it?
EDIT: just noticed that your checkbox is actually on Form2, so why are you setting and saving it in Form1's events?
Re: Can not saving app's settings
Ok, I resolved the problem :) thx for helps.. But I want to write the solution; I was writing the codes in form1 load and form1.closing sections, but I wasn't using X button to close form1. I think this was the source of the problem, I was using my own close button. I changed the codes position, wrote them in form2.load and in the button which hides form2. So, It's working :)