C#实现Winform版计算器

作者:lijiao 时间:2023-01-25 06:59:37 

本文实例为大家分享Winform版计算器的具体实现方法,供大家参考,具体内容如下

前台页面设计

C#实现Winform版计算器

后台代码实现


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 计算器
{
 public partial class Form1 : Form
 {
   double c, d;
   string m;
   public Form1()
   {
     InitializeComponent();
   }

private void button2_Click(object sender, EventArgs e)
   {

}

private void button8_Click(object sender, EventArgs e)
   {
     textBox1.Text += button8.Text;
   }

private void button1_Click(object sender, EventArgs e)
   {
     textBox1.Text += button1.Text;
   }

private void button2_Click_1(object sender, EventArgs e)
   {
     textBox1.Text += button2.Text;

}

private void button3_Click(object sender, EventArgs e)
   {
     textBox1.Text += button3.Text;
   }

private void button4_Click(object sender, EventArgs e)
   {
     textBox1.Text += button4.Text;
   }

private void button5_Click(object sender, EventArgs e)
   {
     textBox1.Text += button5.Text;
   }

private void button6_Click(object sender, EventArgs e)
   {
     textBox1.Text += button6.Text;
   }

private void button7_Click(object sender, EventArgs e)
   {
     textBox1.Text += button7.Text;

}

private void button9_Click(object sender, EventArgs e)
   {
     textBox1.Text += button9.Text;
   }

private void button10_Click(object sender, EventArgs e)
   {
     textBox1.Text += button10.Text;
   }

private void button15_Click(object sender, EventArgs e)
   {
     d= Convert.ToDouble(textBox1.Text);
     switch (m)
     {
       case("+"):
         textBox1.Text = Convert.ToString(c+d);
         break;
       case ("-"):
         textBox1.Text = Convert.ToString(c-d);
         break;
       case ("*"):
         textBox1.Text = Convert.ToString(c * d);
         break;
       case ("/"):
         textBox1.Text = Convert.ToString(c/d);
         break;

}
   }

private void button11_Click(object sender, EventArgs e)
   {
     c = Convert.ToDouble(textBox1.Text);
     textBox1.Text = "";
     m = button11.Text;
   }

private void button12_Click(object sender, EventArgs e)
   {
     c = Convert.ToDouble(textBox1.Text);
     textBox1.Text = "";
     m = button12.Text;
   }

private void button13_Click(object sender, EventArgs e)
   {
     c= Convert.ToDouble(textBox1.Text);
     textBox1.Text = "";
     m = button13.Text;
   }

private void button14_Click(object sender, EventArgs e)
   {
     c = Convert.ToDouble(textBox1.Text);
     textBox1.Text = "";
     m = button14.Text;
   }

private void button16_Click(object sender, EventArgs e)
   {
     textBox1.Text = "";
   }
 }
}
标签:C#,Winform,计算器
0
投稿

猜你喜欢

  • @valid 无法触发BindingResult的解决

    2023-08-10 09:16:12
  • C#实现获取程序路径方法小结

    2022-05-09 19:40:48
  • android APP登陆页面适配的实现

    2022-08-27 17:55:57
  • DUBBO 日志过滤器,输出dubbo 接口调用入参、出参等信息(最新推荐)

    2023-10-19 22:53:54
  • Android性能优化大图治理示例详解

    2023-12-13 00:18:01
  • Android自定义组件获取本地图片和相机拍照图片

    2022-07-09 21:54:48
  • java如何反编译jar包并修改class文件重新打包

    2021-09-20 05:24:26
  • SpringBoot启动访问localhost:8080报错404的解决操作

    2021-07-20 08:44:00
  • 使用FeignClient设置动态Url

    2022-07-04 05:55:39
  • Android 悬浮窗权限各机型各系统适配大全(总结)

    2022-04-27 10:09:53
  • 基于android中的各种颜色在drawable.xml中的值详解

    2022-03-30 01:56:18
  • Java 获取当前时间及实现时间倒计时功能【推荐】

    2022-08-21 16:08:27
  • Java详解数据类型的定义与使用

    2023-09-29 01:35:20
  • 深入学习C#网络编程之HTTP应用编程(上)

    2023-12-12 23:12:27
  • linux操作系统安装MONO执行C#程序的详解步骤

    2022-10-04 18:20:04
  • java基础知识之FileInputStream流的使用

    2021-07-05 00:30:24
  • Unity Shader实现3D翻页效果

    2021-10-07 10:03:45
  • 如何更改Dialog的标题与按钮颜色详解

    2023-06-01 23:54:54
  • java 2d画图示例分享(用java画图)

    2023-07-25 22:03:52
  • Android开发使用Messenger及Handler进行通信的方法示例

    2022-02-23 23:35:22
  • asp之家 软件编程 m.aspxhome.com