我将combobox绑定到一张表的一个字段,代码如下 private void Form1_Load(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "data source=10.0.0.122;database=Kindergarten;user id=sa;password=sa";
            conn.Open();            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select * from BM";
            SqlDataAdapter sa = new SqlDataAdapter(cmd.CommandText, conn);
            DataSet ds = new DataSet();
            sa.Fill(ds);
            this.comboBox2.DataSource = ds.Tables[0];
            this.comboBox2.DisplayMember = "BM_MC";
            this.comboBox2.ValueMember = "BM_DM";
            this.comboBox2.SelectedIndex = -1;
            conn.Close();
        }以上能绑定数据并正常显示,但是我在combobox的下拉箭头中却不能取到值,值为空;
取值代码如下:
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.textBox1.Text = this.comboBox2.SelectedText.ToString().Trim(); 
        }
请问这个问题如何解决?