📄 frmquestions.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Example_1
{
/// <summary>
/// Summary description for frmQuestions.
/// </summary>
public class frmQuestions : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblQuestn1;
private System.Windows.Forms.RadioButton radAns1;
private System.Windows.Forms.RadioButton radAns2;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Button btnExit;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.GroupBox grpQ2;
private System.Windows.Forms.GroupBox grpQ3;
private System.Windows.Forms.RadioButton radAns4;
private System.Windows.Forms.RadioButton radAns3;
private System.Windows.Forms.RadioButton radAns5;
private System.Windows.Forms.RadioButton radAns6;
private System.Windows.Forms.RadioButton radAns7;
private System.Windows.Forms.RadioButton radAns8;
private System.Windows.Forms.GroupBox grpQ1;
// Variable to hold score
public static int score = 0;
public frmQuestions()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
[STAThread]
static void Main()
{
Application.Run(new frmQuestions());
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblQuestn1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.radAns1 = new System.Windows.Forms.RadioButton();
this.radAns2 = new System.Windows.Forms.RadioButton();
this.label1 = new System.Windows.Forms.Label();
this.btnSubmit = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.grpQ1 = new System.Windows.Forms.GroupBox();
this.grpQ2 = new System.Windows.Forms.GroupBox();
this.radAns5 = new System.Windows.Forms.RadioButton();
this.radAns3 = new System.Windows.Forms.RadioButton();
this.radAns4 = new System.Windows.Forms.RadioButton();
this.grpQ3 = new System.Windows.Forms.GroupBox();
this.radAns8 = new System.Windows.Forms.RadioButton();
this.radAns7 = new System.Windows.Forms.RadioButton();
this.radAns6 = new System.Windows.Forms.RadioButton();
this.grpQ2.SuspendLayout();
this.grpQ3.SuspendLayout();
this.SuspendLayout();
//
// lblQuestn1
//
this.lblQuestn1.Location = new System.Drawing.Point(10, 17);
this.lblQuestn1.Name = "lblQuestn1";
this.lblQuestn1.Size = new System.Drawing.Size(374, 25);
this.lblQuestn1.TabIndex = 1;
this.lblQuestn1.Text = "问题 1:羊角掌是一种多汁植物。";
//
// label3
//
this.label3.Location = new System.Drawing.Point(10, 95);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(336, 25);
this.label3.TabIndex = 2;
this.label3.Text = "问题 2:不锈钢是哪一年发明的?";
//
// radAns1
//
this.radAns1.Location = new System.Drawing.Point(29, 52);
this.radAns1.Name = "radAns1";
this.radAns1.Size = new System.Drawing.Size(57, 26);
this.radAns1.TabIndex = 3;
this.radAns1.Text = "正确";
//
// radAns2
//
this.radAns2.Location = new System.Drawing.Point(115, 52);
this.radAns2.Name = "radAns2";
this.radAns2.Size = new System.Drawing.Size(67, 26);
this.radAns2.TabIndex = 4;
this.radAns2.Text = "错误";
//
// label1
//
this.label1.Location = new System.Drawing.Point(10, 224);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(316, 25);
this.label1.TabIndex = 7;
this.label1.Text = "问题 3:约翰?埃德加?胡佛担任什么职务?";
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(29, 362);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(90, 25);
this.btnSubmit.TabIndex = 12;
this.btnSubmit.Text = "提交(&S)";
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(134, 362);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(64, 25);
this.btnExit.TabIndex = 13;
this.btnExit.Text = "退出(&E)";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// grpQ1
//
this.grpQ1.Location = new System.Drawing.Point(16, 43);
this.grpQ1.Name = "grpQ1";
this.grpQ1.Size = new System.Drawing.Size(182, 43);
this.grpQ1.TabIndex = 14;
this.grpQ1.TabStop = false;
//
// grpQ2
//
this.grpQ2.Controls.Add(this.radAns5);
this.grpQ2.Controls.Add(this.radAns3);
this.grpQ2.Controls.Add(this.radAns4);
this.grpQ2.Location = new System.Drawing.Point(16, 121);
this.grpQ2.Name = "grpQ2";
this.grpQ2.Size = new System.Drawing.Size(182, 94);
this.grpQ2.TabIndex = 15;
this.grpQ2.TabStop = false;
//
// radAns5
//
this.radAns5.Location = new System.Drawing.Point(19, 60);
this.radAns5.Name = "radAns5";
this.radAns5.Size = new System.Drawing.Size(67, 26);
this.radAns5.TabIndex = 19;
this.radAns5.Text = "1917";
//
// radAns3
//
this.radAns3.Location = new System.Drawing.Point(19, 9);
this.radAns3.Name = "radAns3";
this.radAns3.Size = new System.Drawing.Size(67, 25);
this.radAns3.TabIndex = 18;
this.radAns3.Text = "1915";
//
// radAns4
//
this.radAns4.Location = new System.Drawing.Point(19, 34);
this.radAns4.Name = "radAns4";
this.radAns4.Size = new System.Drawing.Size(77, 26);
this.radAns4.TabIndex = 17;
this.radAns4.Text = "1913";
//
// grpQ3
//
this.grpQ3.Controls.Add(this.radAns8);
this.grpQ3.Controls.Add(this.radAns7);
this.grpQ3.Controls.Add(this.radAns6);
this.grpQ3.Location = new System.Drawing.Point(6, 250);
this.grpQ3.Name = "grpQ3";
this.grpQ3.Size = new System.Drawing.Size(192, 103);
this.grpQ3.TabIndex = 16;
this.grpQ3.TabStop = false;
//
// radAns8
//
this.radAns8.Location = new System.Drawing.Point(19, 69);
this.radAns8.Name = "radAns8";
this.radAns8.Size = new System.Drawing.Size(125, 26);
this.radAns8.TabIndex = 2;
this.radAns8.Text = "联邦调查局局长";
//
// radAns7
//
this.radAns7.Location = new System.Drawing.Point(19, 43);
this.radAns7.Name = "radAns7";
this.radAns7.Size = new System.Drawing.Size(125, 26);
this.radAns7.TabIndex = 1;
this.radAns7.Text = "美国国防部部长";
//
// radAns6
//
this.radAns6.Location = new System.Drawing.Point(19, 17);
this.radAns6.Name = "radAns6";
this.radAns6.Size = new System.Drawing.Size(125, 26);
this.radAns6.TabIndex = 0;
this.radAns6.Text = "中央情报局局长";
//
// frmQuestions
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(393, 393);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.label1);
this.Controls.Add(this.radAns2);
this.Controls.Add(this.radAns1);
this.Controls.Add(this.label3);
this.Controls.Add(this.lblQuestn1);
this.Controls.Add(this.grpQ1);
this.Controls.Add(this.grpQ2);
this.Controls.Add(this.grpQ3);
this.Name = "frmQuestions";
this.Text = "联机测验";
this.grpQ2.ResumeLayout(false);
this.grpQ3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnSubmit_Click(object sender, System.EventArgs e)
{
//Evaluate the answer for Question 1
if (radAns1.Checked == true)
score = score + 10;
//Evaluate the answer for Question 2
if (radAns4.Checked == true)
score = score + 10;
//Evaluate the answer for Question 3
if (radAns8.Checked == true)
score = score + 10;
// Displaying frmScore
frmScore objfrmScore = new frmScore();
objfrmScore.Show();
this.Hide();
}
// Quit application
private void btnExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -