DataSet ds = new ODMS.BLL.SYS_ENUMERATION().GetList("tablename='T_DeviceType'");
            cbDEVICETYPE.DropDownStyle = ComboBoxStyle.DropDownList;
            cbDEVICETYPE.DataSource = ds.Tables[0].DefaultView;
            cbDEVICETYPE.DisplayMember = "NAME";
            cbDEVICETYPE.ValueMember = "ID";
            cbDEVICETYPE.Items.Add("");//运行到这里出现错误 设置 DataSource 属性后无法修改项集合

解决方案 »

  1.   

    this.comboBox1.SelectedIndex = 需要的值,
      

  2.   

    修改一下你的代码:DataSet ds = new ODMS.BLL.SYS_ENUMERATION().GetList("tablename='T_DeviceType'"); 
    ds.Tables[0].Rows.Insert(0,ds.Tables[0].NewRow());
      

  3.   

    DataSet ds = new ODMS.BLL.SYS_ENUMERATION().GetList("tablename='T_DeviceType'"); ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);
      

  4.   

    try...DataRow dr = ds.Tables[0].NewRow();
    dr["ID"] = "0";
    dr["NAME"] = "";
    ds.Tables[0].Rows.InsertAt(dr, 0);
    cbDEVICETYPE.DataSource = ds.Tables[0].DefaultView;