萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> C#編寫的windows計算器的實例代碼

C#編寫的windows計算器的實例代碼

這篇文章介紹了C#編寫windows計算器的代碼,有需要的朋友可以參考一下   復制代碼 代碼如下:


using System;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
using System.Collections;
using System.ComponentModel;
using System.Data;
namespace comput
{
    /// <summary>
    /// 這是一個計算器的簡單實現。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        #region 控件聲明
        private System.Windows.Forms.TextBox txtShow;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Button btn_rev;
        private System.Windows.Forms.Button btn_dot;
        private System.Windows.Forms.Button btn_add;
        private System.Windows.Forms.Button btn_equ;
        private System.Windows.Forms.Button btn_sign;
        private System.Windows.Forms.Button btn_sub;
        private System.Windows.Forms.Button btn_mul;
        private System.Windows.Forms.Button btn_0;
        private System.Windows.Forms.Button btn_3;
        private System.Windows.Forms.Button btn_2;
        private System.Windows.Forms.Button btn_1;
        private System.Windows.Forms.Button btn_6;
        private System.Windows.Forms.Button btn_5;
        private System.Windows.Forms.Button btn_4;
        private System.Windows.Forms.Button btn_sqrt;
        private System.Windows.Forms.Button btn_div;
        private System.Windows.Forms.Button btn_7;
        private System.Windows.Forms.Button btn_8;
        private System.Windows.Forms.Button btn_9;
        private System.Windows.Forms.MainMenu mainMenu1;
        private System.Windows.Forms.MenuItem menuItem1;
        private System.Windows.Forms.Button btn_sqr;
        private System.Windows.Forms.MenuItem menuItem2;
        private System.Windows.Forms.MenuItem menuItem3;
        private System.Windows.Forms.MenuItem menuItem4;
        private System.Windows.Forms.MenuItem menuItem5;
        private System.Windows.Forms.MenuItem menuItem6;
        private System.Windows.Forms.Button c;
        private System.Windows.Forms.Button ce;
        private System.Windows.Forms.MenuItem menuItem8;
        private System.Windows.Forms.MenuItem menuItem9;
        private System.Windows.Forms.MenuItem menuItem10;
        /// <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 );
        }
       #endregion
        #region 各控件的屬性的方法Windows Form Designer generated code
        /// <summary>
        /// 設計器支持所需的方法 - 不要使用代碼編輯器修改
        /// 此方法的內容。
        /// </summary>
        private void InitializeComponent()
        {
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
            this.txtShow = new System.Windows.Forms.TextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.c = new System.Windows.Forms.Button();
            this.ce = new System.Windows.Forms.Button();
            this.btn_rev = new System.Windows.Forms.Button();
            this.btn_dot = new System.Windows.Forms.Button();
            this.btn_add = new System.Windows.Forms.Button();
          

copyright © 萬盛學電腦網 all rights reserved