[C#]组合框设计windows加减乘除简单计算器应用
2014-05-09 16:44
435 查看
组合框使用方法,按照下面图片上提示,设计一个windows应用程序,实现不同运算。
界面设计:
代码:
运行:
界面设计:
代码:
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 combox { public partial class Form1 : Form { public Form1() { InitializeComponent(); label1.Text = "="; button1.Text = "选择不同运算符进行计算"; comboBox1.Items.Add("+"); comboBox1.Items.Add("-"); comboBox1.Items.Add("*"); comboBox1.Items.Add("/"); } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { float a, b, c; a = Convert.ToSingle(textBox1.Text); b = Convert.ToSingle(textBox2.Text); if (comboBox1.Text== "+") { c = a + b; textBox3.Text = c.ToString(); } else if (comboBox1.Text == "-") { c = a - b; textBox3.Text = c.ToString() ; } else if (comboBox1.Text == "*") { c = a * b; textBox3.Text = c.ToString(); } else { c = a / b; textBox3.Text = c.ToString(); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } } }
运行:
相关文章推荐
- Windows应用开发中常用的设计模式
- Thrift应用:Windows下C#服务端实现
- 【本人译作推荐】Windows 8应用开发:C#和XAML卷(原名:Building Windows 8 Apps with C# and XAML)
- Windows 8 应用开发实践——labmu版Tunet(一):功能设计
- 在C#应用中,设计自己的配置文件
- 如何在Visual Studio 2017中使用C# 7+语法 构建NetCore应用框架之实战篇(二):BitAdminCore框架定位及架构 构建NetCore应用框架之实战篇系列 构建NetCore应用框架之实战篇(一):什么是框架,如何设计一个框架 NetCore入门篇:(十二)在IIS中部署Net Core程序
- C# Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法
- 使用C#开发Metro 风格应用的路线图 -- metro设计原则
- MSP430单片机课程设计(c#窗体应用)
- 设计模式的实际应用——在C#中解决单客户端窗口数据并发问题(2010-08-04)
- C#Windows窗体界面设计_01_绘制三角函数_五点作图法
- C#设计模式之桥接模式分析和应用
- 在Windows 8 Metro应用中使用C# 连接SQLite
- C# windows程序应用与JavaScript 程序交互实现例子
- 如何设计一个好的 Windows 8 应用?
- C#Windows窗体界面设计_01_绘制三角函数_附强制类型转换
- c# 程序设计及应用教程上机A.2.3————字符提取和整数整除联系(Console)
- .net 下C# 创建windows 服务应用系统
- C#Windows窗体界面设计_攻击决策项目_02_设计窗体_04_修订主窗体工具栏和状态栏
- 用C#设计Windows应用程序模板