title: Disappearing Dynamic ComboBox
body: <p>Created the following code to workout some bugs in a bigger program.  That said, when I click the button to add a row, the next row is added, but the previously created ComboBox (cmboPhoneType) disappears with each new click.  What am I missing how to correct?  Does this maybe have something to do with the name of the control?</p>
  <pre><code>using System;
  using System.Data;
  using System.Drawing;
  using System.Windows.Forms;
  using MySql.Data.MySqlClient;
  
  namespace AddNewRowTest
  {
      public partial class Form1 : Form
      {
        
          int leftControl = 1;
          ComboBox cmboPhoneType = new ComboBox();
         
  
  
          public Form1()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              addLabels();
              btn_AddRow.PerformClick();
          }
  
          private void btn_AddRow_Click(object sender, EventArgs e)
          {
              
  
              //Connection Information redacted
              reConn.Open();
  
              MySqlCommand phoneTypeCommand = new MySqlCommand(&quot;Select * from lutable_phonetype order by Type;&quot;, reConn);
              MySqlDataAdapter phoneTypeAdapter = new MySqlDataAdapter();
              DataTable phoneTypeTable = new DataTable();
              phoneTypeAdapter.SelectCommand = phoneTypeCommand;
              phoneTypeAdapter.Fill(phoneTypeTable);
              
              this.Controls.Add(cmboPhoneType);
              cmboPhoneType.Top = leftControl * 36;
              cmboPhoneType.Left = 12;
              cmboPhoneType.Size = new Size(100, 20);
              cmboPhoneType.DataSource = phoneTypeTable;
              cmboPhoneType.DisplayMember = &quot;Type&quot;;
              cmboPhoneType.ValueMember = &quot;TypeID&quot;;
              cmboPhoneType.DataBindings.Add(&quot;SelectedValue&quot;, phoneTypeTable, &quot;TypeID&quot;);
              cmboPhoneType.SelectedIndexChanged += new System.EventHandler(cmboPhoneType_SelectedIndexChanged);
  
              MaskedTextBox msktxtPhone = new MaskedTextBox();
              this.Controls.Add(msktxtPhone);
              msktxtPhone.Top = leftControl * 36;
              msktxtPhone.Left = 116;
              msktxtPhone.Size = new Size(100, 20);
              msktxtPhone.Mask = &quot;(999) 000-0000&quot;;
  
              reConn.Close();
              leftControl++;
             
          }
  
          private void addLabels()
          {
              Label lblPhoneType = new Label();
              this.Controls.Add(lblPhoneType);
              lblPhoneType.Top = leftControl * 12;
              lblPhoneType.Left = 12;
              lblPhoneType.Text = &quot;Phone Type&quot;;
  
              Label lblPhoneNumber = new Label();
              this.Controls.Add(lblPhoneNumber);
              lblPhoneNumber.Top = leftControl * 12;
              lblPhoneNumber.Left = 116;
              lblPhoneNumber.Text = &quot;Phone Number&quot;;
          }
  
       
          private void cmboPhoneType_SelectedIndexChanged(object sender, EventArgs e)
          {
              cmboPhoneType.DataBindings.Clear();
          }
         
         
      }
  }
  </code></pre>