/// <summary> /// 加载公司 /// </summary> /// <param name="cbbCompany">Combobox</param> public static void LoadValues2Company(System.Windows.Forms.ComboBox cbbCompany) { cbbCompany.DataSource = null; Company oComp = new Company(); cbbCompany.DisplayMember = "NAME_CHS"; cbbCompany.ValueMember = "ID"; DataTable _dt = oComp.GetValidCompany(); cbbCompany.DataSource = BaseClass.LoadInvalidValueToCombobox(_dt, "ID", "NAME_CHS");
/// <summary> /// 加载一个无意义的值到Combobox控件 /// </summary> /// <param name="dtSource">Combobox控件数据源</param> /// <param name="sValue">ValueMember字段</param> /// <param name="sDisplay">DisplayMember字段</param> /// <returns></returns> public static DataTable LoadInvalidValueToCombobox(DataTable dtSource, String sValue, String sDisplay) { DataRow _drNew = dtSource.NewRow(); _drNew[sValue] = 0; _drNew[sDisplay] = "请选择"; dtSource.Rows.InsertAt(_drNew, 0); dtSource.AcceptChanges(); return dtSource; }