當(dāng)前位置:首頁 > IT技術(shù) > Windows編程 > 正文

C# winform combobox 在綁定數(shù)據(jù)之后插入一項(xiàng)選擇項(xiàng)
2021-08-10 19:04:20

/// <summary> /// 填充comboboxB超醫(yī)師 /// </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 = "全部"; }

本文摘自 :https://blog.51cto.com/u

開通會(huì)員,享受整站包年服務(wù)立即開通 >