private void testComboBox_SelectedIndexChanged(object sender, EventArgs e) { TestScoreListView.Items.Clear(); dateComboBox.Items.Clear(); string error = ""; List <ResultDisplay> resultList = new List <ResultDisplay>(); List <TestSession> sessionList = new List <TestSession>(); UserClass user = (UserClass)patientComboBox.SelectedItem; Test test = (Test)testComboBox.SelectedItem; TestSession testsession = (TestSession)dateComboBox.SelectedItem; // Displays test results for a selected user. try { if (TestSession.GetTestDate(sessionList, ref error, user.intUserID, test.TestID)) { foreach (TestSession session in sessionList) { dateComboBox.Items.Add(session); } } else { MessageBox.Show("Grr"); } } catch { MessageBox.Show("Error in form!"); } if (dateComboBox.Items.Count == 1) { dateComboBox.SelectedIndex = 0; } }