读取其显示值(text):this.cobobox1.SelectedText.ToString()
与查询数据库结果绑定:
//sql语句
string sql_ShuM = " select " + changyongziliaoEntity.ID + " as ID "
+ "," + changyongziliaoEntity.cMC + " as 属名 "
+ " from " + changyongziliaoEntity.tName
+ " where " + changyongziliaoEntity.nZT + "=1 and " + changyongziliaoEntity.cLB + "='shu'";
OleDbDataAdapter oleZhongM = new OleDbDataAdapter(sql_ShuM, oleCon);
DataTable dtShuM = new DataTable();
oleZhongM.Fill(dtShuM);
this.comboBox2.DataSource = dtShuM.DefaultView;
this.comboBox2.DisplayMember = "属名";
this.comboBox2.ValueMember = "ID";
给ComboBox赋值:
this.diqu_comboBox.Items.Add("--请选择--");
this.diqu_comboBox.Items.Add("--湛江市--");
this.diqu_comboBox.Items.Add("--廉江市--");
this.diqu_comboBox.Items.Add("--雷州市--");
this.diqu_comboBox.Items.Add("--徐闻县--");
this.diqu_comboBox.Items.Add("--吴川市--");
this.diqu_comboBox.Items.Add("--遂溪县--");