我想知道是否有方法暫時隱藏或刪除正在從數據庫填充的組合框中的項目?暫時隱藏Combobox中的項目
我正在由同一列填充(往返機號)兩個組合框
你不能真的MOTOR1連接到MOTOR1,總之不必重新填充整個組合框的每次選擇時,我都在想,必須有一種方法暫時隱藏第二個組合框中的相同選擇。
請讓我知道如果你需要關於如何在組合框被填充(代碼等)
編輯這裏的信息是組合框的人口代碼:
void PopulateCreateView(CableID_CreateView CView)
{
// Creates a new Model, and gets data from the Db.
CModel = new CableID_Model();
CModel.CNId = 1;
Database_Facade.Operation_Switch(OPREAD);
// Populates the form with data for the Plant Area Codes, Supplier Info and Major Equipment.
foreach (PlantAreaCode_Model Model in PlantAreaCode_Controller.PList)
{
CView.cmbAreaCode.Items.Add(Model.AreaName);
CView.lblDummy.Text = Model.AreaName;
if (CView.lblDummy.Width > CView.cmbAreaCode.DropDownWidth)
{
// Sets the width +20 to allow for the scroll bar.
CView.cmbAreaCode.DropDownWidth = CView.lblDummy.Width + 20;
}
}
foreach (SupplierID_Model Model in SupplierID_Controller.SList)
{
if (Model.CondConfig != null) { CView.cmbXsec.Items.Add(Model.CondConfig); }
if (Model.Insulation != null)
{
CView.cmbInsulation.Items.Add(Model.Insulation);
CView.lblDummy.Text = Model.Insulation;
if (CView.lblDummy.Width > CView.cmbInsulation.DropDownWidth)
{
// Sets the width +20 to allow for the scroll bar.
CView.cmbInsulation.DropDownWidth = CView.lblDummy.Width + 20;
}
}
}
foreach (MajorEquipment_Model Model in MajorEquipment_Controller.MeList)
{
CView.cmbFromLoc.Items.Add(Model.EqipmentNumber);
CView.cmbToLoc.Items.Add(Model.EqipmentNumber);
}
}
這裏對於MySQL查詢代碼:
public void GetCableId(CableID_Model CModel)
{
DbConnect();
try
{
MajorEquipment_Controller.MeList = new List<MajorEquipment_Model>();
mySqlCommand = mySqlConnect.CreateCommand();
mySqlCommand.CommandText = "SELECT * FROM MajorEquipment;";
mySqlReader = mySqlCommand.ExecuteReader();
while (mySqlReader.Read())
{
MajorEquipment_Controller.MeList.Add(new MajorEquipment_Model
{
EqipmentNumber = Convert.ToString(mySqlReader["EquipmentNumber"])
});
}
mySqlReader.Close();
mySqlCommand.ExecuteNonQuery();
}
catch (MySqlException e) { MessageBox.Show(e.Message); }
finally
{
if (mySqlConnect != null)
{
mySqlConnect.Close();
}
}
}