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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
System.Windows.Forms.Button[] Buttons;
System.Windows.Forms.TextBox[] TextBoxs;
int Case, i;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TextBoxs = new System.Windows.Forms.TextBox[1];
TextBoxs[0] = new TextBox();
this.Controls.Add(TextBoxs[0]);
TextBoxs[0].Size = new Size(190, 10);
TextBoxs[0].Location = new System.Drawing.Point(10, 60);
TextBoxs[0].Enabled = false;
Buttons = new System.Windows.Forms.Button[16];
for (int i = 0; i < 16; ++i)
{
Buttons[i] = new Button();
Buttons[i].Click += new System.EventHandler(Buttons_Click);
Buttons[i].Size = new Size(40, 40);
this.Controls.Add(Buttons[i]);
if (i <= 3)
Buttons[i].Location = new System.Drawing.Point(10 + i * 50, 250);
else if (i > 3 && i <= 7)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 4) * 50, 200);
else if (i > 7 && i <= 11)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 8) * 50, 150);
else if (i > 11 && i <= 15)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 12) * 50, 100);
}
Buttons[0].Text = "0";
Buttons[1].Text = "00";
Buttons[2].Text = "=";
Buttons[3].Text = "+";
Buttons[4].Text = "1";
Buttons[5].Text = "2";
Buttons[6].Text = "3";
Buttons[7].Text = "-";
Buttons[8].Text = "4";
Buttons[9].Text = "5";
Buttons[10].Text = "6";
Buttons[11].Text = "*";
Buttons[12].Text = "7";
Buttons[13].Text = "8";
Buttons[14].Text = "9";
Buttons[15].Text = "/";
}
public void Buttons_Click(object sender, EventArgs e)
{
Buttons[0].Click+=new EventHandler( Buttons0_Click) ;
Buttons[4].Click += new EventHandler(Buttons4_Click);
}
public void Buttons0_Click(object sender, EventArgs e)
{
TextBoxs[0].Text+=0;
}
public void Buttons4_Click(object sender, EventArgs e)
{
TextBoxs[0].Text = TextBoxs[0].Text + "1";
}
}
}
沒有留言:
張貼留言