private void Classes_SelectedIndexChanged(object sender, EventArgs e) { if (!ComboBoxChangeable) { return; } ComboBoxChangeable = false; EditButton.Enabled = false; string Choosing = Subjects.SelectedItem.ToString(); Subjects.Items.Clear(); Subjects.Items.Add("All"); StudentServices service = new StudentServices(); var data = service.GetSubjectFromDB(Classes.SelectedItem.ToString()); foreach (string Subject in data) { Subjects.Items.Add(Subject); } if (!Subjects.Items.Contains(Choosing)) { Subjects.SelectedIndex = 0; } else { Subjects.SelectedIndex = Subjects.Items.IndexOf(Choosing); } if (listViewInfo == ListViewInfo.Students) { ViewStudents_Click(sender, e); } else if (listViewInfo == ListViewInfo.Scoreboard) { ViewScore_Click(sender, e); } else if (listViewInfo == ListViewInfo.Schedule) { ViewSchedule_Click(sender, e); } ComboBoxChangeable = true; }
public ManagerForm() { InitializeComponent(); openFileDialog.Filter = "Comma-separated values files (*.csv)|*.csv"; openFileDialog.RestoreDirectory = true; NotiLabel.Text = ""; _No = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Id = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Name = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _Info7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); _No.Text = "No."; _No.Width = 40; ComboBoxChangeable = false; Classes.Items.Add("All"); Classes.SelectedIndex = 0; Subjects.Items.Add("All"); Subjects.SelectedIndex = 0; ComboBoxChangeable = true; StudentServices service = new StudentServices(); var data = service.GetClassesFromDB("All"); foreach (string Class in data) { Classes.Items.Add(Class); } data = service.GetSubjectFromDB("All"); foreach (string Subject in data) { Subjects.Items.Add(Subject); } }