title: How to Set default combobox
body: <p>So I've been looking to set a default value for my combobox. I found a few things but none of them seem to work.</p>
  
  <p>Actually, it works if I create a simple combobox and use <code>comboBox1.SelectedIndex = comboBox1.Items.IndexOf("something")</code> but once I dynamically generate the contents of the comboboxes, I can't get it to work anymore.</p>
  
  <p>This is how I fill my combo box (located in the class's constructor);</p>
  
  <pre><code>        string command = "SELECT category_id, name FROM CATEGORY ORDER BY name";
          List&lt;string[]&gt; list = database.Select(command, false);
  
          cbxCategory.Items.Clear();
  
          foreach (string[] result in list)
          {
              cbxCategory.Items.Add(new ComboBoxItem(result[1], result[0]));
          }
  </code></pre>
  
  <p>I can't seem to get it to work to set a default value, like if I place <code>cbxCategory.SelectedIndex = cbxCategory.Items.IndexOf("New")</code> below the above code, it won't work.</p>
  
  <p>WinForms, by the way.</p>
  
  <p>Thank you in advance.</p>