有一表a  有name 和 count 两个字段 ,comboBox1绑定的是name ,
根据comboBox1的选择结果,将对应的记录内容放到
text1.text 
text2.text
谢谢。

解决方案 »

  1.   

    comboBox,属性Text绑定name,Value绑定count不行就了
      

  2.   

    在选择的时候 先选出两列,一列是name  一列是count 将name绑定到combobox count存到一个数组中
    当combobox中的值被选定的时候,可以得到被选定的行的索引,对应的数组如 count[索引]就是count的值了
      

  3.   

    text1.text=combobox1.text;
    string str="select count from  表 where name='"+combobox1.text.trim()+"'";
    conn.open();//conn在前应有定义 
    sqlcommand cmd=new sqlcommand(sql,conn); 
    cmd.CommandType = CommandType.Text; 
    string strCount = Convert.ToString(cmd.ExecuteNonQuery()); 
    text2.text=strCount;
    //没区分大小写
      

  4.   

    将数据库里的表读出来放到数据集里; 
    this.cbo .DataSource = Dataset.Table[0]//将cbo的数据源绑定到数据集           
    this.cbo .DisplayMember = "name"; //cbo的的显示层绑定name字段
    this.cbo .ValueMember = "count";  //cbo的的数值层绑定count字段
    //这样CBO的没一项都同时有两个值了 private void cbo_SelectedIndexChanged(object sender, EventArgs e)//cbo的索引变化引发的事件
            {
                this.text1.Text=this.cbo.text;
                this.text2.Text=this.cbo.SelectedValue.ToString();          
            }
    或者你不会用数据集,就用DataReade从数据库一条一条读出来,再加到Cbo的Items里面
      

  5.   

    SelectedIndexChanged事件函数里面获得其所需要的值,不就可以了吗?
      

  6.   


     private void PlaySet_Load(object sender, EventArgs e)
            {
                this.conndb();
                da = new OleDbDataAdapter(@"select * from TwSoft ", dbconn); 
                DataSet ds = new DataSet();
                da.Fill(ds, "TwSoft");
                this.comboBox1.DataSource = ds.Tables["TwSoft"];
                this.comboBox1.DisplayMember = "C_SoftName";
                  this.comboBox1.ValueMember = "C_SoftCount";             
            }
    private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
            {
                this.textBox1.Text= comboBox1.Text;
                this.textBox2.Text = this.comboBox1.SelectedValue.ToString();        }
    //我这样写有问题吗,为什么只有textbox2.text 与选择是同步的。textbox1的值却是上一次操作的。
      

  7.   

      你的事件用错了我的
    _SelectedIndexChanged
    你的
    _SelectionChangeCommitted