using c#

C# winform combobox(dropdownlist) 在绑定数据之后插入一项选择项

09-09-22 21:52   View:679

原文地址:http://blog.csdn.net/geovindu1/archive/2009/02/17/3895228.aspx

 

/// <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 = "全部";  
 


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/geovindu1/archive/2009/02/17/3895228.aspx

PS:以上方法完全可行~

Feedback


  • No comments posted yet.
Title:
 
Name:
 
URL:

Comments:
 

Because of the cache,you may see your comments several minutes later.


Main Feeds

Contact Me Privacy

All Rights Reservered CnKker.Com 2006~2009 Powder By 龍天昌盛 QQ:256051