/// <summary> /// 填充comboboxB超医师 /// </summary> private void setDBPyhNameComboBox() { this.combPhy.DataSource = null; DBConnectioin dbc = new DBConnectioin(); SqlConnection conn = new SqlConnection(DBConnectioin.conStr); conn.Open(); //DbHelperSQL.setComboList(combPhy, "select PhyID,PhyName from Physician", "Physician", "PhyName", "PhyID"); string sSQL = "select PhyID,PhyName from Physician"; string sTable = "Physician"; DataSet dsCourtesy = new DataSet(); SqlDataAdapter daCourtesy = new SqlDataAdapter(); DbHelperSQL.setCommand(dsCourtesy, daCourtesy, sSQL, sTable); daCourtesy.Fill(dsCourtesy); combPhy.DataSource = dsCourtesy.Tables[0].DefaultView; DataRow dr = dsCourtesy.Tables[0].NewRow(); combPhy.DisplayMember = "PhyName"; combPhy.ValueMember = "PhyID"; dr["PhyName"] = "全部"; dr["PhyID"] = -1; dsCourtesy.Tables[0].Rows.InsertAt(dr, 0); //combPhy.Text = "全部"; }
C# winform combobox 在绑定数据之后插入一项选择项
原创
©著作权归作者所有:来自51CTO博客作者geovin的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
mysql binlog查看指定数据库
mysql binlog查看指定数据库的方法。
mysql 二进制日志 MySQL -
向ComboBox控件绑定数据
独到的视角理解datareader对象
职场 休闲 ComboBox