Results 1 to 6 of 6

Thread: [RESOLVED] Can not saving app's settings

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    62

    Resolved [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

    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

    So what's wrong with my G.S.S project?
    (Sorry because of my terrible English )
    Visual Basic.Net || "As powerful as you"


  2. #2
    Addicted Member
    Join Date
    Aug 2006
    Posts
    160

    Re: Can not saving app's settings

    Quote Originally Posted by canavaroski90 View Post
    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

    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

    So what's wrong with my G.S.S project?
    (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.

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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()
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    62

    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?
    Visual Basic.Net || "As powerful as you"


  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    62

    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
    Visual Basic.Net || "As powerful as you"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width