C#程序设计---->计算圆面积windows程序
2014-10-09 23:28
447 查看
值得说的就是添加一个回车事件,
http://blog.csdn.net/nanwang314/article/details/6176604
这个样子就可以添加一个回车事件…………
Form1.cs
http://blog.csdn.net/nanwang314/article/details/6176604
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode==Keys.Enter) { MessageBox.Show("您在textBox1里按下了回车键"); } }
这个样子就可以添加一个回车事件…………
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CircleAreaW { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double r; r = double.Parse(txtR.Text); MyCircle aCircle = new MyCircle(r); double aArea = aCircle.CircleArea(); dblArea.Text = aArea.ToString("f4"); } private void txtR_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { MessageBox.Show("您在textBox1里按下了回车键"); double r; r = double.Parse(txtR.Text); MyCircle aCircle = new MyCircle(r); double aArea = aCircle.CircleArea(); dblArea.Text = aArea.ToString("f4"); } } } }
Form1.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CircleAreaW { class MyCircle { double circleR; public MyCircle(double dblR) { circleR = dblR; } public double CircleArea() { double dblArea = Math.PI * circleR * circleR; return dblArea; } } }
相关文章推荐
- 简单的C#Windows 窗体编程,计算圆的周长、面积与体积。
- C#Windows Service服务程序的安装/卸载、启动/停止 桌面客户端管理程序设计
- MFC Windows 程序设计->WinMain 简单Windows程序 命令行编译
- 1、通过程序设计几何图形(Shape)、矩形(Rectangle)、圆形(Circle)、正方形(Square)几种类型,能够利用接口和多态性计算几何图形的面积和周长并显示。 2、按以下要求编写程序
- 我的第一个Qt程序:使用Qt creator和Qt designer完成"HelloWorld"和计算圆面积的程序设计
- 我的第一个Qt程序:使用Qt creator和Qt designer完成"HelloWorld"和计算圆面积的程序设计
- C#程序调用 Windows 记事本程序
- c#写windows服务程序
- C#建立了一个windows程序,如何防止多个程序实例运行?
- 字符串表达式计算C#程序设计
- C#中windows程序全屏如何设置
- C#Windows 服务制作安装删除. 用户注销后,程序继续运行
- C#中windows程序使用播放功能
- C# Windows窗體應用程序如何啟動運行?
- c# 做 windows 托盘程序
- 关于如何在C#程序中访问windows用户的密码:
- 王晓东原创:C# 简易IDE开发工具-快速创建Windows和Web程序及Web Service服务!
- 用C#写一个简单的WINDOWS服务程序
- 用带参数的宏设计一个计算矩形面积的程序
- <<展现C#>> 前言(补充) 和第三章 第一个C#程序(修订)