我正在尝试在 formLoad 方法中填充多个组合框,但仅填充第一个组合框。在这种相同的方法中,为数据网格调用相同的存储过程并且工作正常。请看附件代码:
private void frmMain_Load(object sender, EventArgs e)
{
DataAccessLayer dal = new DataAccessLayer();
pnlEditCall.Visible = false;
pnlEditInspection.Visible = false;
pnlEditEquipment.Visible = false;
#region Populate DataGrids
dgvInspections.DataSource = dal.GetAllInspections();
dgvCalls.DataSource = dal.GetAllCalls();
dgvStaff.DataSource = dal.GetAllStaff();
dgvLabs.DataSource = dal.GetAllLabs();
dgvEquipment.DataSource = dal.GetAllEquipment();
#endregion
#region Populate ComboBoxes
cmbInspectionStaff.DataSource = dal.GetAllStaff();
cmbInspectionStaff.DisplayMember = "Name";
cmbInspectionStaff.ValueMember = "[StaffID]";
cmbCallStaff.DataSource = dal.GetAllStaff();
cmbCallStaff.DisplayMember = "Name";
cmbCallStaff.ValueMember = "[StaffID]";
cmbCurrentLab.DataSource = dal.GetAllLabs();
cmbCurrentLab.ValueMember = "[LabNo]";
cmbCurrentLab.DisplayMember = "[LabNo]";
#endregion
}