兄弟,你value加上值了后,要再选中才行,否则会出现你上面的错误。取当前值用this.comboBox1.text

解决方案 »

  1.   

    这样试试:string valueStr;
    if (this.comboBox1.SelectedIndex != -1)
        valueStr = this.comboBox1.SelectedValue.ToString();如果还不行,把出问题的语句包在try中,调试一下,看看异常信息。
      

  2.   

    this.comboBox6.DataSource = ds.Tables["种类"].DefaultView;
    this.comboBox6.DisplayMember = "种类名称";
    this.comboBox6.ValueMember = "种类编号";
    ******************************************************
    if (this.comboBox6.SelectedIndex != -1)
    int num = Convert.ToInt32(this.comboBox6.SelectedValue);
      

  3.   

    写个类封装VALUE和TEXT就可以了:
    public class CItem
    {
    private int m_v;
    private string m_t; public CItem(int v, string t)
    {
    m_v=v;
    m_t=t;
    }
    public override string ToString()
    {
    return m_t;
    } public int Value()
    {
    return m_v;
    }}//添加到COMBOBOX中
    this.comboBox1.Items.Add(new CItem(1, "aaa"));
    this.comboBox1.Items.Add(new CItem(2, "bbb"));//读出VLAUE和TEXT
    CItem Item=(CItem)this.comboBox1.SelectedItem;
    MessageBox.Show(Item.ToString());
    MessageBox.Show(Item.Value().ToString());
      

  4.   

    不要读取数据库里的,那怕是得到了text value之后,那如何把 value读取出来呢?