private void btnUpdate_Click(object sender, EventArgs e) { Form updateScores = new frmUpdateStudentScores(); selected = lblxstudents.SelectedIndex; if (lblxstudents.Items.Count > 0) { updateScores.ShowDialog(); } else { MessageBox.Show("Student info not in data"); } addToLB(); }
//method where user can update student information private void btnUpdate_Click(object sender, EventArgs e) { Form updateScores = new frmUpdateStudentScores(); //selecting the index of the list box can update student information selected = lbxStudents.SelectedIndex; //if-else statment that checks for existing student data. if (lbxStudents.Items.Count > 0) { updateScores.ShowDialog(); } else { MessageBox.Show("Student's information not in the data", "Error"); } //clears the list box lbxStudents.Items.Clear(); //add student to list box addToListBox(); }