title: Getting selected value of a combobox
body: <pre><code>public class ComboboxItem { 
              public string Text { get; set; } 
              public string Value { get; set; }
              public override string ToString() { return Text; } 
          }
  
  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
              int selectedIndex = comboBox1.SelectedIndex;
              int selecteVal = (int)comboBox1.SelectedValue; 
              ComboboxItem selectedCar = (ComboboxItem)comboBox1.SelectedItem;
              MessageBox.Show(String.Format("Index: [{0}] CarName={1}; Value={2}", selectedIndex, selectedCar.Text, selecteVal));
          }
  </code></pre>
  
  <p>I'm adding them like:</p>
  
  <pre><code>ComboboxItem item = new ComboboxItem();
                      item.Text = cd.Name;
                      item.Value = cd.ID;
                      this.comboBox1.Items.Add(item);
  </code></pre>
  
  <p>I keep getting a NullReferenceExeption and not sure why. the text seems to show up just fine.</p>