comboBox 有几项我想取出其中的一项怎么取啊 !!

解决方案 »

  1.   

    this.comboBox2.SelectedValue.ToString();
      

  2.   

    comboBox2.SelectedValue.ToString();--------這個你不是綁定了ValueMember的話取不到值﹐只能comboBox2.text或者comboBox2.SelectedIndex
      

  3.   

    this.comboBox1.SelectedItem.ToString();  ----这个取自己添加在Item中的值this.comboBox2.SelectedValue.ToString(); ----这个取动态绑定的值
      

  4.   

    我问的不是这个意思
    comboBox1.Items.IndexOf()
    能返回索引
    有没有一个函数给了索引返回值
    比如 我 在代码里添加项
    我可以随意 给它设置 索引
      

  5.   

    string sqlstr = "select workItem from workCombox";
                conn.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlstr,conn);
                DataTable dr = new DataTable();
                adapter.Fill(dr);
                comboBox1.DataSource = dr.DefaultView;
    为什么绑定的 值是System.Data.Defaultview
      

  6.   

    string sqlstr = "select workItem from workCombox";
                conn.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlstr,conn);
                DataTable dr = new DataTable();
                adapter.Fill(dr);
                comboBox1.DataSource = dr.DefaultView;
    -------------------加多這下面這几個             
               comboBox1.DisplayMember = "顯示的字段";
                comboBox1.ValueMember = "數據字段";