private void frmResource_Load(object sender, EventArgs e) { try { CommonUtil.BindComboBox(cboResourceType, "ID", "Name", CommonUtil.listResourceType); CommonUtil.BindComboBox(cboResourceModel, "Id", "Name", CommonUtil.listResourceModel); CommonUtil.BindComboBox(cboSubject, "CourseID", "CourseName", CommonUtil.listSubject); if (CommonUtil.listSubject.Count == 2) { cboSubject.SelectedIndex = 1; } else { cboSubject.SelectedIndex = 0; } publicClass.BindDataGridViewColumn(dgvResult.Columns["ResourceModel"] as DataGridViewComboBoxColumn, "Id", "Name", CommonUtil.listResourceModel); cboResourceModel.SelectedValueChanged += cboResourceModel_SelectedValueChanged; cboSubject.SelectedValueChanged += cboSubject_SelectedValueChanged; } catch (Exception ex) { LogHelper.WriteLog(typeof(frmHomeWork), ex); CommonUtil.WriteLog(ex); } }