public ViewStoredQuizzes() { InitializeComponent(); QuestionClass qc = new QuestionClass(); Quizzes = qc.LoadQuizzes("%"); //Loads the quizzes from the database that contain any question text QuizListBox.DataSource = Quizzes; //Sets the source for the list box to be the loaded quizzes QuizListBox.DisplayMember = "Name"; //The displayed item from the stored quizzes to be the name of the quiz //Hides the quiz display info so that it only appears when the user clicks on an item QuizNameLabel.Hide(); InsertQuizNameLabel.Hide(); QuestionsLabel.Hide(); QuestionsListBox.Hide(); ExpandButton.Hide(); }
private void QuizListBox_MouseDoubleClick(object sender, MouseEventArgs e) { //Displays the quiz info QuizNameLabel.Show(); InsertQuizNameLabel.Show(); QuestionsLabel.Show(); QuestionsListBox.Show(); ExpandButton.Show(); ChosenQuiz = (StoredQuizzes)QuizListBox.SelectedItem; //The chosen quiz is saved to be the selected item from the list view InsertQuizNameLabel.Text = ChosenQuiz.Name; //The quiz name is displayed QuestionClass qc = new QuestionClass(); SelectedQuestionsId = qc.FindQuestionsId(ChosenQuiz); //Retrives the quiz`s questions ID`s from the database SelectedQuestions = qc.GetStoredQuizQuestions(SelectedQuestionsId); //The ID`s related questions are then returned from the database QuestionsListBox.DataSource = SelectedQuestions; //The data source for the list box displaying the questions is set to the questions QuestionsListBox.DisplayMember = "Question"; //The displayed item from the stored quizzes to be the name of the quiz }