none
CheckBox.... Save settings??? RRS feed

  • Question

  • I have looked in the other thread that had some of the same prob. but is just won't save the settings ..

    could some one give me as small sample of how to set it up??or walk threw??

    Thanks

    • Moved by CoolDadTx Monday, April 23, 2012 1:47 PM Winforms related (From:Visual C# General)
    Monday, April 23, 2012 3:46 AM

Answers

  • Do you mean saving the value of checkbox to settings and reverse.

    In the form load you can assign settings to checkbox.

    private void Form_Load(object sender, EventArgs e)
    {
        chkIsSSL.Checked = Properties.Settings.Default.IsSSL;
    }

    On the checked changed you can do the reverse.

    private void chkIsSSK_CheckedChanged(object sender, EventArgs e)
    {
        Properties.Settings.Default.IsSSL = chkIsSSL.Checked;
        Properties.Settings.Default.Save();
    }


    Resolving n Evolving in C# (http://jeanpaulva.com)

    • Marked as answer by superlurker Tuesday, April 24, 2012 6:53 AM
    Monday, April 23, 2012 4:04 AM
  • Hi superlurker,

      Properties.Settings.Default.checkbox1 would be stored in Application and User Settings all the time, when you are running your program,you will read its lastest change.Next if you want to synchronize  Checked of Checkbox control, you only need to run checkBox1.Checked = Properties.Settings.Default.checkBox1 inside in Form_Loading event handler.If you want to get the more information about using Settings in C# ,you can refer to this link:

      http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 4:20 AM
    Moderator

All replies

  • Do you mean saving the value of checkbox to settings and reverse.

    In the form load you can assign settings to checkbox.

    private void Form_Load(object sender, EventArgs e)
    {
        chkIsSSL.Checked = Properties.Settings.Default.IsSSL;
    }

    On the checked changed you can do the reverse.

    private void chkIsSSK_CheckedChanged(object sender, EventArgs e)
    {
        Properties.Settings.Default.IsSSL = chkIsSSL.Checked;
        Properties.Settings.Default.Save();
    }


    Resolving n Evolving in C# (http://jeanpaulva.com)

    • Marked as answer by superlurker Tuesday, April 24, 2012 6:53 AM
    Monday, April 23, 2012 4:04 AM
  • Thanks that worked....... but how do you start with it checked, form some reason i can get it to start checked?? I tried changing it in the Properties settings to true that didn't work??
    Monday, April 23, 2012 11:50 AM
  • Set default value of check box true. that works and while applying setting values just check whether it is checked or not

    Gyana Ranjan Panda

    • Proposed as answer by Gyana Monday, April 23, 2012 12:37 PM
    Monday, April 23, 2012 12:36 PM
  • tried that, maybe i did it wrong ... I went to  Properties settings ... and I tried

    checkBox1.Checked = true;

    then....

    checkBox1.Checked = Properties.Settings.Default.checkBox1;

    this makes it checked all the time...???

    Monday, April 23, 2012 3:11 PM
  • Hi superlurker,

      Properties.Settings.Default.checkbox1 would be stored in Application and User Settings all the time, when you are running your program,you will read its lastest change.Next if you want to synchronize  Checked of Checkbox control, you only need to run checkBox1.Checked = Properties.Settings.Default.checkBox1 inside in Form_Loading event handler.If you want to get the more information about using Settings in C# ,you can refer to this link:

      http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx

      Sincerely,

      Jason Wang


    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 4:20 AM
    Moderator