c# comboBox1 获取value

SqlConnection  conn=new SqlConnection("server=(local);database=Hotelsystem;user id=sa;password=sa;");
   SqlDataAdapter da=new SqlDataAdapter("select Dic_Code,Dic_Name from Dic_District",conn);
   DataSet ds=new DataSet();
   da.Fill(ds,"Dic_District");
   this.comboBox1.DataSource=ds.Tables["Dic_District"];
   this.comboBox1.DisplayMember="Dic_Name";   //显示的列
   this.comboBox1.ValueMember="Dic_Code";     //数据列,次列会在selectedvalue中显示

 

 

private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   textBox1.Text=this.comboBox1.SelectedValue.ToString();
  
  }

你可能感兴趣的:(combobox)