private void Button1_Click(object sender, EventArgs e) { if (n >= 2 && elem.CorectAnswer != null) { elem.Answers = new List <string>(); elem.Answers.AddRange(answs); answs.Clear(); testElems.Add(elem); elem = null; listBox1.Items.Clear(); label4.Text = $"Questions ({testElems.Count()})"; textBox4.Clear(); textBox4.Enabled = true; checkBox1.Text = "IsRight"; if (!checkBox1.Enabled) { checkBox1.Enabled = true; } else { checkBox1.Checked = false; } n = 0; MessageBox.Show($"Question: {testElems[testElems.Count() - 1].Question}\nNum of answers: {testElems[testElems.Count() - 1].Answers.Count()}\nCorect Answer: {testElems[testElems.Count() - 1].CorectAnswer}"); } else { MessageBox.Show("Error"); } }
private void Button2_Click(object sender, EventArgs e) { if (n == 0) { if (textBox4.Text.Trim() != "" && textBox3.Text.Trim() != "") { elem = new TestElem() { Question = textBox4.Text.Trim() }; answs.Add(textBox3.Text.Trim()); if (checkBox1.Checked) { elem.CorectAnswer = textBox3.Text.Trim(); checkBox1.Checked = false; checkBox1.Enabled = false; checkBox1.Text = $"IsRight ({elem.CorectAnswer})"; } textBox4.Enabled = false; textBox3.Clear(); textBox1.Enabled = textBox2.Enabled = false; ShowInListBox(); n++; } } else { if (textBox3.Text.Trim() != "") { // foreach (var t in answs) { if (t == textBox3.Text.Trim()) { MessageBox.Show("There are such answer!"); return; } } // answs.Add(textBox3.Text.Trim()); if (checkBox1.Checked) { elem.CorectAnswer = textBox3.Text.Trim(); checkBox1.Checked = false; checkBox1.Enabled = false; checkBox1.Text = $"IsRight ({elem.CorectAnswer})"; button1.Enabled = true; button3.Enabled = true; } textBox3.Clear(); ShowInListBox(); n++; } } }