效果展示:
1. 进入页面:
2. 答题界面:
3. 时间截止界面:
4. 提交界面:
起始页代码
public partial class Start : Form
{
public Start()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
Test t = new Test();
t.Show();
this.Hide();
}
}
考试页面代码
public partial class Test : Form
{
public int currentTime = 0;
public int num = 0;
public Test()
{
InitializeComponent();
button2.Visible = false;
}
private void 视图ToolStripMenuItem_Click(object sender, EventArgs e)
{
Start s = new Start();
this.Hide();
s.Show();
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void Test_Load(object sender, EventArgs e)
{
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Start();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
currentTime = Convert.ToInt32(label2.Text);
currentTime -= 1;
label2.Text = Convert.ToString(currentTime);
if(currentTime == 0)
{
timer1.Stop();
System.Media.SystemSounds.Asterisk.Play();
MessageBox.Show("时间到!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private void label6_Click(object sender, EventArgs e)
{
}
private void label7_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Check(groupBox1, "✔");
Check(groupBox2, "✔");
Check(groupBox3, "✔");
Check(groupBox4, "✔");
Check(groupBox5, "✔");
a.Enabled = false;
b.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
radioButton5.Enabled = false;
radioButton6.Enabled = false;
radioButton7.Enabled = false;
radioButton8.Enabled = false;
radioButton9.Enabled = false;
radioButton10.Enabled = false;
label6.Text = Convert.ToString(num);
label7.Text = Convert.ToString(num * 20);
this.timer1.Stop();
button2.Visible = true;
}
public void Check(GroupBox s, String db)
{
foreach(Control D in s.Controls)
{
if (((RadioButton)D).Checked == true && ((RadioButton)D).Text.Substring(0, 1) == db)
{
num++;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
label2.Text = "20";
label6.Text = "0";
label7.Text = "0";
this.timer1.Start();
this.timer1.Interval = 1000;
Clean(groupBox1);
Clean(groupBox2);
Clean(groupBox3);
Clean(groupBox4);
Clean(groupBox5);
a.Enabled = true;
b.Enabled = true;
radioButton3.Enabled = true;
radioButton4.Enabled = true;
radioButton5.Enabled = true;
radioButton6.Enabled = true;
radioButton7.Enabled = true;
radioButton8.Enabled = true;
radioButton9.Enabled = true;
radioButton10.Enabled = true;
button2.Visible = false;
num = 0;
}
public void Clean(GroupBox s)
{
foreach(Control D in s.Controls)
{
if(((RadioButton)D).Checked == true)
{
((RadioButton)D).Checked = false;
}
}
}
}
有图标的应用程序
到此这篇关于基于C#制作考试答题系统的文章就介绍到这了,更多相关C#答题系统内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!