windows forms 简单例子
写一个求和界面的图形程序

前两个文本框定义name为 theNum1,theNum2
结果框定义name为theAns
按钮定义name为theAddbut
有代码
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 visSum
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void theAddbut_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(theNum1.Text);
int b = Convert.ToInt32(theNum2.Text);
int c = a + b;
theAns.Text = Convert.ToString(c);
}
}
}
运行结果:


浙公网安备 33010602011771号