⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 一个简单的计算器程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace 四则运算器
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button buttonC;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.Button button6;
		private System.Windows.Forms.Button buttonEqu;
		private System.Windows.Forms.Button buttonSub;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button buttonMul;
		private System.Windows.Forms.Button buttonDiv;
		private System.Windows.Forms.Button buttonDot;
		private System.Windows.Forms.Button buttonPN;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button0;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.Button buttonPlus;
		private System.Windows.Forms.Button button9;
		private System.Windows.Forms.Button button8;
		private System.Windows.Forms.Button button7;
		private System.Windows.Forms.Button buttonBack;
		private System.Windows.Forms.Button buttonRM;
		private System.Windows.Forms.Button buttonM;
		private System.Windows.Forms.Label labelOut;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.buttonC = new System.Windows.Forms.Button();
			this.button5 = new System.Windows.Forms.Button();
			this.button6 = new System.Windows.Forms.Button();
			this.buttonEqu = new System.Windows.Forms.Button();
			this.buttonSub = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.buttonMul = new System.Windows.Forms.Button();
			this.buttonDiv = new System.Windows.Forms.Button();
			this.buttonDot = new System.Windows.Forms.Button();
			this.buttonPN = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button0 = new System.Windows.Forms.Button();
			this.button1 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			this.buttonPlus = new System.Windows.Forms.Button();
			this.button9 = new System.Windows.Forms.Button();
			this.button8 = new System.Windows.Forms.Button();
			this.button7 = new System.Windows.Forms.Button();
			this.buttonBack = new System.Windows.Forms.Button();
			this.buttonRM = new System.Windows.Forms.Button();
			this.buttonM = new System.Windows.Forms.Button();
			this.labelOut = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// buttonC
			// 
			this.buttonC.DialogResult = System.Windows.Forms.DialogResult.Ignore;
			this.buttonC.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonC.ForeColor = System.Drawing.Color.Red;
			this.buttonC.Location = new System.Drawing.Point(16, 72);
			this.buttonC.Name = "buttonC";
			this.buttonC.Size = new System.Drawing.Size(48, 40);
			this.buttonC.TabIndex = 1;
			this.buttonC.TabStop = false;
			this.buttonC.Text = "C";
			this.buttonC.Click += new System.EventHandler(this.buttonC_Click);
			// 
			// button5
			// 
			this.button5.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button5.Location = new System.Drawing.Point(80, 184);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(48, 40);
			this.button5.TabIndex = 2;
			this.button5.TabStop = false;
			this.button5.Text = "5";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// button6
			// 
			this.button6.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button6.Location = new System.Drawing.Point(144, 184);
			this.button6.Name = "button6";
			this.button6.Size = new System.Drawing.Size(48, 40);
			this.button6.TabIndex = 3;
			this.button6.TabStop = false;
			this.button6.Text = "6";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// buttonEqu
			// 
			this.buttonEqu.Font = new System.Drawing.Font("Batang", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonEqu.Location = new System.Drawing.Point(16, 352);
			this.buttonEqu.Name = "buttonEqu";
			this.buttonEqu.Size = new System.Drawing.Size(240, 40);
			this.buttonEqu.TabIndex = 4;
			this.buttonEqu.Text = "=";
			this.buttonEqu.Click += new System.EventHandler(this.buttonEqu_Click);
			// 
			// buttonSub
			// 
			this.buttonSub.Font = new System.Drawing.Font("仿宋_GB2312", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonSub.Location = new System.Drawing.Point(208, 184);
			this.buttonSub.Name = "buttonSub";
			this.buttonSub.Size = new System.Drawing.Size(48, 40);
			this.buttonSub.TabIndex = 5;
			this.buttonSub.TabStop = false;
			this.buttonSub.Text = "-";
			this.buttonSub.Click += new System.EventHandler(this.buttonSub_Click);
			// 
			// button3
			// 
			this.button3.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button3.Location = new System.Drawing.Point(144, 240);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(48, 40);
			this.button3.TabIndex = 6;
			this.button3.TabStop = false;
			this.button3.Text = "3";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// buttonMul
			// 
			this.buttonMul.Font = new System.Drawing.Font("仿宋_GB2312", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonMul.Location = new System.Drawing.Point(208, 240);
			this.buttonMul.Name = "buttonMul";
			this.buttonMul.Size = new System.Drawing.Size(48, 40);
			this.buttonMul.TabIndex = 7;
			this.buttonMul.TabStop = false;
			this.buttonMul.Text = "*";
			this.buttonMul.Click += new System.EventHandler(this.buttonMul_Click);
			// 
			// buttonDiv
			// 
			this.buttonDiv.Font = new System.Drawing.Font("仿宋_GB2312", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonDiv.Location = new System.Drawing.Point(208, 296);
			this.buttonDiv.Name = "buttonDiv";
			this.buttonDiv.Size = new System.Drawing.Size(48, 40);
			this.buttonDiv.TabIndex = 8;
			this.buttonDiv.TabStop = false;
			this.buttonDiv.Text = "/";
			this.buttonDiv.Click += new System.EventHandler(this.buttonDiv_Click);
			// 
			// buttonDot
			// 
			this.buttonDot.Font = new System.Drawing.Font("Arial", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonDot.Location = new System.Drawing.Point(144, 296);
			this.buttonDot.Name = "buttonDot";
			this.buttonDot.Size = new System.Drawing.Size(48, 40);
			this.buttonDot.TabIndex = 9;
			this.buttonDot.TabStop = false;
			this.buttonDot.Text = ".";
			this.buttonDot.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.buttonDot.Click += new System.EventHandler(this.buttonDot_Click);
			// 
			// buttonPN
			// 
			this.buttonPN.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonPN.Location = new System.Drawing.Point(80, 296);
			this.buttonPN.Name = "buttonPN";
			this.buttonPN.Size = new System.Drawing.Size(48, 40);
			this.buttonPN.TabIndex = 10;
			this.buttonPN.TabStop = false;
			this.buttonPN.Text = "+/-";
			this.buttonPN.Click += new System.EventHandler(this.buttonPN_Click);
			// 
			// button2
			// 
			this.button2.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button2.Location = new System.Drawing.Point(80, 240);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(48, 40);
			this.button2.TabIndex = 11;
			this.button2.TabStop = false;
			this.button2.Text = "2";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button0
			// 
			this.button0.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button0.Location = new System.Drawing.Point(16, 296);
			this.button0.Name = "button0";
			this.button0.Size = new System.Drawing.Size(48, 40);
			this.button0.TabIndex = 12;
			this.button0.TabStop = false;
			this.button0.Text = "0";
			this.button0.Click += new System.EventHandler(this.button0_Click);
			// 
			// button1
			// 
			this.button1.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button1.Location = new System.Drawing.Point(16, 240);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(48, 40);
			this.button1.TabIndex = 13;
			this.button1.TabStop = false;
			this.button1.Text = "1";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button4
			// 
			this.button4.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button4.Location = new System.Drawing.Point(16, 184);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(48, 40);
			this.button4.TabIndex = 14;
			this.button4.TabStop = false;
			this.button4.Text = "4";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// buttonPlus
			// 
			this.buttonPlus.Font = new System.Drawing.Font("仿宋_GB2312", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonPlus.Location = new System.Drawing.Point(208, 128);
			this.buttonPlus.Name = "buttonPlus";
			this.buttonPlus.Size = new System.Drawing.Size(48, 40);
			this.buttonPlus.TabIndex = 15;
			this.buttonPlus.TabStop = false;
			this.buttonPlus.Text = "+";
			this.buttonPlus.Click += new System.EventHandler(this.buttonPlus_Click);
			// 
			// button9
			// 
			this.button9.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button9.Location = new System.Drawing.Point(144, 128);
			this.button9.Name = "button9";
			this.button9.Size = new System.Drawing.Size(48, 40);
			this.button9.TabIndex = 16;
			this.button9.TabStop = false;
			this.button9.Text = "9";
			this.button9.Click += new System.EventHandler(this.button9_Click);
			// 
			// button8
			// 
			this.button8.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button8.Location = new System.Drawing.Point(80, 128);
			this.button8.Name = "button8";
			this.button8.Size = new System.Drawing.Size(48, 40);
			this.button8.TabIndex = 17;
			this.button8.TabStop = false;
			this.button8.Text = "8";
			this.button8.Click += new System.EventHandler(this.button8_Click);
			// 
			// button7
			// 
			this.button7.Font = new System.Drawing.Font("Arial", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button7.Location = new System.Drawing.Point(16, 128);
			this.button7.Name = "button7";
			this.button7.Size = new System.Drawing.Size(48, 40);
			this.button7.TabIndex = 18;
			this.button7.TabStop = false;
			this.button7.Text = "7";
			this.button7.Click += new System.EventHandler(this.button7_Click);
			// 
			// buttonBack
			// 
			this.buttonBack.Font = new System.Drawing.Font("黑体", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.buttonBack.Location = new System.Drawing.Point(208, 72);
			this.buttonBack.Name = "buttonBack";
			this.buttonBack.Size = new System.Drawing.Size(48, 40);
			this.buttonBack.TabIndex = 19;
			this.buttonBack.TabStop = false;
			this.buttonBack.Text = "←";
			this.buttonBack.Click += new System.EventHandler(this.buttonBack_Click);
			// 
			// buttonRM
			// 
			this.buttonRM.Font = new System.Drawing.Font("Arial", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonRM.Location = new System.Drawing.Point(144, 72);
			this.buttonRM.Name = "buttonRM";
			this.buttonRM.Size = new System.Drawing.Size(48, 40);
			this.buttonRM.TabIndex = 20;
			this.buttonRM.TabStop = false;
			this.buttonRM.Text = "RM";
			this.buttonRM.Click += new System.EventHandler(this.buttonRM_Click);
			// 
			// buttonM
			// 
			this.buttonM.Font = new System.Drawing.Font("Arial", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonM.Location = new System.Drawing.Point(80, 72);
			this.buttonM.Name = "buttonM";
			this.buttonM.Size = new System.Drawing.Size(48, 40);
			this.buttonM.TabIndex = 21;
			this.buttonM.TabStop = false;
			this.buttonM.Text = "M";
			this.buttonM.Click += new System.EventHandler(this.buttonM_Click);
			// 
			// labelOut
			// 
			this.labelOut.BackColor = System.Drawing.Color.White;
			this.labelOut.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.labelOut.Location = new System.Drawing.Point(16, 16);
			this.labelOut.Name = "labelOut";
			this.labelOut.Size = new System.Drawing.Size(240, 32);
			this.labelOut.TabIndex = 22;
			this.labelOut.Text = "0";
			this.labelOut.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// Form1
			// 
			this.AcceptButton = this.buttonEqu;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.buttonC;
			this.ClientSize = new System.Drawing.Size(272, 405);
			this.Controls.Add(this.labelOut);
			this.Controls.Add(this.buttonM);
			this.Controls.Add(this.buttonRM);
			this.Controls.Add(this.buttonBack);
			this.Controls.Add(this.button7);
			this.Controls.Add(this.button8);
			this.Controls.Add(this.button9);
			this.Controls.Add(this.buttonPlus);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.button0);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.buttonPN);
			this.Controls.Add(this.buttonDot);
			this.Controls.Add(this.buttonDiv);
			this.Controls.Add(this.buttonMul);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.buttonSub);
			this.Controls.Add(this.buttonEqu);
			this.Controls.Add(this.button6);
			this.Controls.Add(this.button5);
			this.Controls.Add(this.buttonC);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -