private void refreshProfs_Click() { try { profBS = new BindingSource(Profs.GetAll(), ""); ProfsGridView.DataSource = profBS; ProfsNavigator.BindingSource = profBS; comboBox1.DataSource = profBS; if (profBS.Count > 0) { comboBox1.Enabled = true; var tbs = new BindingSource(Profs.GetAll(), "") { new Profs("All Professors") }; comboBox1.DataSource = tbs; comboBox1.DisplayMember = "ProfName"; comboBox1.SelectedIndex = comboBox1.Items.Count - 1; } else { comboBox1.Enabled = false; } } catch (Exception) { MessageBox.Show("Could not connect to SQL Server" + "\n" + "Please make sure SQL server express is installed"); err = 1; } }
public AddCourse() { InitializeComponent(); allprofs = new ArrayList(); allprofs.Add(new Profs("No Prof Assigned")); foreach (Profs pf in Profs.GetAll()) { allprofs.Add(pf); } comboBox1.DataSource = allprofs; comboBox1.DisplayMember = "ProfName"; this.ValidateChildren(); }