在单个事件中填充多个组合框

时间:2013-10-06 22:31:39

标签: c# combobox

我正在尝试在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
     }

0 个答案:

没有答案