Не работает переход на другой вопрос в тесте C#
private void button2_Click(object sender, EventArgs e)
{
if (selected_response == correct_answers_number) correct_answers = correct_answers + 1;
if(selected_response != correct_answers_number)
{
wrong_answers = wrong_answers + 1;
array[wrong_answers] = label1.Text;
}
if (button2.Text == "қайтадан тесті бастау")
{
button2.Text = "келесі сұрақ";
radioButton1.Visible = true;
radioButton2.Visible = true;
radioButton3.Visible = true;
Start();
return;
}
if (button2.Text == "аяқтау")
{
Read.Close();
radioButton1.Visible = false;
radioButton2.Visible = false;
radioButton3.Visible = false;
label1.Text = String.Format("Тестілеу аяқталды.\n" +
"дұрыс жауап: {0} из {1}.\n" +
"жиналған ұпай: {2:F2}.", correct_answers,
quection_count, (correct_answers * 5.0F) / quection_count);
button2.Text = "қайтадан бастау";
var Str = "Тізім " +
":\n\n";
for (int i = 1; i <= wrong_answers; i++)
Str = Str + array[i] + "\n";
if (wrong_answers != 0) MessageBox.Show(
Str, "Тестілеу аяқталды");
}
if (button2.Text == "келесі сұрақ") Вопрос();
}
Ответы (1 шт):
Автор решения: Алексей Пушкин
→ Ссылка
У Вас return в третьем if мешает.
private void button2_Click(object sender, EventArgs e)
{
if (selected_response == correct_answers_number)
correct_answers++;
else
{
wrong_answers++;
array[wrong_answers] = label1.Text;
}
Button2Check();
}
private void Button2Check()
{
if (button2.Text == "қайтадан тесті бастау")
{
button2.Text = "келесі сұрақ";
RadioButtonsViseble(true);
Start();
}
else if (button2.Text == "аяқтау")
{
Read.Close();
RadioButtonsViseble(false);
button2.Text = "қайтадан бастау";
label1.Text = String.Format("Тестілеу аяқталды.\n" +
"дұрыс жауап: {0} из {1}.\n" + "жиналған ұпай: {2:F2}.",
correct_answers, quection_count,
(correct_answers * 5.0F) / quection_count);
ShowWrongAnswers();
}
else if (button2.Text == "келесі сұрақ")
Вопрос(); //Используйте английские наименования
}
private void RadioButtonsViseble(bool IsVisible)
{
radioButton1.Visible = IsVisible;
radioButton2.Visible = IsVisible;
radioButton3.Visible = IsVisible;
}
private void ShowWrongAnswers()
{
if (wrong_answers == 0) return;
var Str = "Тізім :\n\n";
for (int i = 1; i <= wrong_answers; i++)
Str = Str + array[i] + "\n";
MessageBox.Show(Str, "Тестілеу аяқталды");
}