title: C# getting a checkbox value from one form to another
body: <p>After hours of puzzling I think I have missed the obvious here. I am sure it is not this difficult. I have a Form (CommTester) that has a checkbox on it. On this same form I have a ToolStrip with an item that will start another form (SetPrintGoDelay). This form needs to know if the checkbox on form 1 is checked or not. The snippet below shows how I am trying to get the CommTester Form and send it to SetPrintGoDelay Form. (All code has large amounts cut out to make it fit easier, ask if you think I have missed a vital bit out)</p>
  
  <pre><code>    namespace comms_test
      {
         public partial class CommTester : Form
        {
             public CommTester()
             {
                 InitializeComponent();
                 EnableControls();
                 btn_connect.Visible = true;
                 btn_disconnect.Visible = false;
                 toolStripStatusLabel1.Text = "Disconnected";
            }
  
      private void chkbx_log_CheckedChanged(object sender, EventArgs e)
             {
                 SetPrintGoDelay form2;
                 form2 = new SetPrintGoDelay(this);
                 form2.Show();
             }
  
      public string checkboxchecked()
      {
          if (chkbx_log.Checked == true)
          {
              return "1";
          }
          else
          {
              return "0";
          }
      }
  
     }
     }
  </code></pre>
  
  <p>Now in the SetPrintGoDelay Form</p>
  
  <pre><code>namespace comms_test
  {
  
  
  public partial class SetPrintGoDelay : Form
  {
  
      CommTester main;        
  
  
      public SetPrintGoDelay(CommTester incomingform)
      {
         InitializeComponent();
         main = incomingform;
         MessageBox.Show(main.checkboxchecked().ToString());
      }
  
       private void btn_setprintgodelay_Click(object sender, EventArgs e)
      {
          if (main.checkboxchecked().ToString() == "1")
          {
              CommTester frm1 = new CommTester();
              frm1.log_data(DataToLog); //go and log the data
          }
       }
  </code></pre>
  
  <p>So on the CommTester Form I tick the checkbox and I get it logging the data but immediately it is done the checkbox value is set to 0 and it will not pick it up again as 1 even though it is still checked. I think we may have disposed of it and I do not seem to be able to get the value again. As I say after hours of trying things I am obviously missing the obvious. If there is an easier way of getting the value of checkbox from one form to another please let me know.</p>