zoukankan      html  css  js  c++  java
  • C# winform combobox 在绑定数据之后插入一项选择项

           /**//// <summary>
            /// 填充comboboxB超医师 geovindu@163.com 涂聚文
            ///2009-02-16
            /// </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 = "全部";
    
    
            }
    
    
    
    
    默认让combobox选择一项
    comboBox.SelectIndex = 0
    
  • 相关阅读:
    js38---门面模式
    js37---Function.prototype
    js36---函数嵌套
    js35
    js34
    js33--责任链模式
    js32---CommonUtil.js
    龙芯服务器参数
    SQLSERVER 秘钥整理
    IOMETER的简单使用
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/2030063.html
Copyright © 2011-2022 走看看