这篇文章主要为大家详细介绍了如何利用C#制作带窗体的考试答题系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
效果展示:
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#答题系统内容请搜索得得之家以前的文章希望大家以后多多支持得得之家!
沃梦达教程
本文标题为:基于C#制作考试答题系统
基础教程推荐
猜你喜欢
- C# windows语音识别与朗读实例 2023-04-27
- 一个读写csv文件的C#类 2022-11-06
- winform把Office转成PDF文件 2023-06-14
- C# List实现行转列的通用方案 2022-11-02
- ZooKeeper的安装及部署教程 2023-01-22
- unity实现动态排行榜 2023-04-27
- C#类和结构详解 2023-05-30
- C#控制台实现飞行棋小游戏 2023-04-22
- C# 调用WebService的方法 2023-03-09
- linux – 如何在Debian Jessie中安装dotnet core sdk 2023-09-26