title: How can I save the state of a group of Radio Buttons in my program?
body: <p>I have two groups of radio buttons (2 groups of 4 buttons), which I would like to save the checked status of and load the checked status as soon as the program/main form loads up. The radio buttons are <strong>NOT</strong> on the main form.</p>
  
  <p>How can I do this using Properties.Settings?</p>
  
  <p>The code on the "Preference" form is as follows:</p>
  
  <pre><code>public string DataFormat, KeyboardFormat;
  
  public void UpdateUserChoice(string date, string keyboard)
      {
          if (date == ddmmyyyy.Text)
              ddmmyyyy.Checked = true;
          else if (date == mmddyyyy.Text)
              mmddyyyy.Checked = true;
          else if (date == yyyyddmm.Text)
              yyyyddmm.Checked = true;
          else if (date == yyyymmdd.Text)
              yyyymmdd.Checked = true;
          //----------------------------------------------------------
          if (keyboard == qwerty.Text)
              qwerty.Checked = true;
          else if (keyboard == qwertz.Text)
              qwertz.Checked = true;
          else if (keyboard == azerty.Text)
              azerty.Checked = true;
          else if (keyboard == dvorak.Text)
              dvorak.Checked = true;
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          if (ddmmyyyy.Checked)
              DataFormat = ddmmyyyy.Text;
          else if (mmddyyyy.Checked)
              DataFormat = mmddyyyy.Text;
          else if (yyyyddmm.Checked)
              DataFormat = yyyyddmm.Text;
          else if (yyyymmdd.Checked)
              DataFormat = yyyymmdd.Text;
          //--------------------------------------------------
          if (qwerty.Checked)
              KeyboardFormat = qwerty.Text;
          else if (qwertz.Checked)
              KeyboardFormat = qwertz.Text;
          else if (azerty.Checked)
              KeyboardFormat = azerty.Text;
          else if (dvorak.Checked)
              KeyboardFormat = dvorak.Text;
          this.Close();
      }
  </code></pre>
  
  <p>And the code on the MainForm is:</p>
  
  <pre><code>private void DateStamp()
      {
          if (dateFormat.ToUpper() == "DD/MM/YYYY")
          {
              int CaretPosition = richTextBoxPrintCtrl1.SelectionStart;
              string TextBefore = richTextBoxPrintCtrl1.Text.Substring(0, CaretPosition);
              string textAfter = richTextBoxPrintCtrl1.Text.Substring(CaretPosition);
              string currentDate = DateTime.Now.ToString("dd-MM-yyyy");
              richTextBoxPrintCtrl1.SelectedText = currentDate;
          }
          else if (dateFormat.ToUpper() == "MM/DD/YYYY")
          {
              int CaretPosition = richTextBoxPrintCtrl1.SelectionStart;
              string TextBefore = richTextBoxPrintCtrl1.Text.Substring(0, CaretPosition);
              string textAfter = richTextBoxPrintCtrl1.Text.Substring(CaretPosition);
              string currentDate = DateTime.Now.ToString("MM-dd-yyyy");
              richTextBoxPrintCtrl1.SelectedText = currentDate;
          }
          else if (dateFormat.ToUpper() == "YYYY/DD/MM")
          {
              int CaretPosition = richTextBoxPrintCtrl1.SelectionStart;
              string TextBefore = richTextBoxPrintCtrl1.Text.Substring(0, CaretPosition);
              string textAfter = richTextBoxPrintCtrl1.Text.Substring(CaretPosition);
              string currentDate = DateTime.Now.ToString("yyyy-dd-MM");
              richTextBoxPrintCtrl1.SelectedText = currentDate;
          }
          else if (dateFormat.ToUpper() == "YYYY/MM/DD")
          {
              int CaretPosition = richTextBoxPrintCtrl1.SelectionStart;
              string TextBefore = richTextBoxPrintCtrl1.Text.Substring(0, CaretPosition);
              string textAfter = richTextBoxPrintCtrl1.Text.Substring(CaretPosition);
              string currentDate = DateTime.Now.ToString("yyyy-MM-dd");
              richTextBoxPrintCtrl1.SelectedText = currentDate;
  
  private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
      {
          UserPreferences pref = new UserPreferences();
          pref.UpdateUserChoice(dateFormat, keyboardFormat);
          pref.ShowDialog();
          dateFormat = pref.DataFormat;
          keyboardFormat = pref.KeyboardFormat;
      }
  
  
      private void virtualKeyboardToolStripMenuItem1_Click(object sender, EventArgs e)
      {
          if (keyboardFormat.ToUpper() == "QWERTY")
          {
              Virtual_Keyboard vKeyboard = new Virtual_Keyboard();
              vKeyboard.Show();
          }
          else if (keyboardFormat.ToUpper() == "QWERTZ")
          {
              QWERTZ qwertz = new QWERTZ();
              qwertz.Show();
          }
          else if (keyboardFormat.ToUpper() == "AZERTY")
          {
              AZERTY azerty = new AZERTY();
              azerty.Show();
          }
          else if (keyboardFormat.ToUpper() == "DVORAK")
          {
              DVORAK dvorak = new DVORAK();
              dvorak.Show();
          }
          }
  </code></pre>
  
  <p>I would like to save the checked status of the radio buttons (as seen in the picture attached), so that when the user reopens the program, these "settings" are also loaded. How would I achieve this? Using Properties.Settings if it's possible.</p>
  
  <p>I've created two "Settings". DatePreference and KeyboardPreference. I don't know what "type" they should be, either. If somebody could guide me, I'd really appreciate it. I'm new to programming so thank you for your help.</p>
  
  <p>The RadioButtons are named:</p>
  
  <p>ddmmyyyy
  mmddyyyy
  yyyyddmm
  yyyymmdd</p>
  
  <p>qwerty
  qwertz
  azerty
  dvorak</p>
  
  <p>Thanks for your help.</p>
  
  <p>--EDIT--</p>
  
  <p>I forgot to mention that this is a WinForms application.</p>
  
  <p><img src="https://i.stack.imgur.com/bw3BN.png" alt="Settings"></p>
  
  <p><img src="https://i.stack.imgur.com/wvTZ4.png" alt="Preferences Dialog"></p>