title: Textbox values get cleared on form.Show
body: <p>I have a form class whose constructor takes a  bunch of parameters which are used to populate the controls on the form. They consist of a checkbox, a couple combo boxes, a date time picker, and a couple textboxes. The textboxes appear blank when the form is rendered. If I step through the code I see the textbox.Text fields being set correctly, but when form.Show is called, the values get cleared. All the other controls retain the values passed into the constructor.</p>
  
  <p>These forms are all built dynamically. I don't see why this would be happening, no other code is run between the constructor and the render.</p>
  
  <pre><code>public partial class Disposition : Form
  {
      string _ncmID;
      int _baseNumber;
      string _type;
      string _by;
      string _partNo;
      DateTime _date;
      int _qty;
      bool _supplierCaused;
      string _notes;
      DateTime _dateReturned;
      frmMain _parentForm;
      GroupBox gbDisposition;
      CheckBox cbSupplierCaused;
      TextBox txtDispQuantity;        
      Label lblQuantity;
      DateTimePicker dtDate;
      Label lblDate;
      ComboBox cboBy;
      Label lblBy;
      TextBox txtNotes;
      Label lblNotes;
      DateTimePicker dtDateReturned;
      ComboBox cboPart; 
  
  public Disposition(frmMain parent, string type, string by, DateTime date, int qty, bool supplierCaused, 
          string partNo, string notes, string ncmID, int baseNumber, DateTime dateReturned)
      {
          InitializeComponent();
  
          _parentForm = parent;            
          _type = type;
          _by = by;
          _qty = qty;
          _date = date;
          _supplierCaused = supplierCaused;
          _partNo = partNo;
          _notes = notes;
          _ncmID = ncmID;
          _baseNumber = baseNumber;
          _dateReturned = dateReturned;
  
          switch (_type)
          {
              case "Scrap":                    
                  DrawScrap(true);
                  break;
              case "Rework":
                  DrawRework(true);
                  break;
              case "Return to Vendor":
                  DrawReturn(true);
                  break;
              case "Use as Is":
                  DrawUse(true);
                  break;
              case "Void":
                  DrawVoid(true);
                  break;
              default:
                  break;
          }
  
      }
  </code></pre>
  
  <p>Each Draw method adds controls to the form, e.g. </p>
  
  <pre><code> txtDispQuantity = new TextBox();
   txtDispQuantity.Location = new Point(248, 31);
   txtDispQuantity.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
   txtDispQuantity.Size = new Size(55, 20);
   txtDispQuantity.Validating += new CancelEventHandler(txtDispQuantity_Validating);
   txtDispQuantity.Text = _qty.ToString();
   gbDisposition.Controls.Add(txtDispQuantity);
  </code></pre>
  
  <p>So I'm just setting the Text property of the Textbox and then adding it to the groupbox. Everything appears fine if I inspect the class in the debugger but once Show is called
  the Text fields are cleared and appear red in the watch window. All the other controls retain the values set in the Draw method.</p>
  
  <p>The only thing happening in the form_load is a combobox setup (adding strings to the items list).</p>
  
  <pre><code>private void txtDispQuantity_Validating(object sender, CancelEventArgs e)
  {
      int q;
  
      if (!Int32.TryParse(txtDispQuantity.Text, out q))
      {
          MessageBox.Show("Please enter an integer value for the quantity", "NCM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      }
  }
  </code></pre>
  
  <p>Nowhere in the code am I setting the Text field for these controls to anything but the values retrieved from the database, which are never empty since the validation doesn't allow it...</p>