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.TextBox[] textBoxes;
System.Windows.Forms.Button[] Buttons;
int i=1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBoxes = new System.Windows.Forms.TextBox[16];
textBoxes[i] = new TextBox();
this.Controls.Add(textBoxes[i]);
textBoxes[i].Location = new System.Drawing.Point(i * 10, 10);
textBoxes[i].Size = new Size(260, 22);
Buttons = new System.Windows.Forms.Button[16];
for (int j = 0; j < 16; j++)
{
Buttons[j] = new Button();
this.Controls.Add(Buttons[j]);
if (j <= 3)
Buttons[j].Location = new System.Drawing.Point(10 + j * 65, 50);
else if (j > 3 && j <= 7)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 4) * 65, 80);
else if (j > 7 && j <= 11)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 8) * 65, 110);
else if (j > 11 && j <= 15)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 12) * 65, 140);
Buttons[j].Size = new Size(60, 23);
}
for (int j = 0; j < 10; j++)
{
Buttons[j].Text = "" + j + "";
}
for (int j = 10; j < 11; j++)
{ Buttons[j].Text = ".";
}
for (int j = 11; j < 12; j++)
{ Buttons[j].Text = "=";
}
for (int j = 12; j < 13; j++)
{
Buttons[j].Text = "+";
}
for (int j = 13; j < 14; j++)
{
Buttons[j].Text = "-";
}
for (int j = 14; j < 15; j++)
{
Buttons[j].Text = "*";
}
for (int j = 15; j < 16; j++)
{
Buttons[j].Text = "/";
}
}
}
}
-------------------------------------------------------------------------------------------------------------
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.TextBox[] textBoxes;
System.Windows.Forms.Button[] Buttons;
int i = 1, bno,j;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBoxes = new System.Windows.Forms.TextBox[16];
textBoxes[i] = new TextBox();
this.Controls.Add(textBoxes[i]);
textBoxes[i].Location = new System.Drawing.Point(i * 10, 10);
textBoxes[i].Size = new Size(260, 22);
Buttons = new System.Windows.Forms.Button[16];
for (int j = 0; j < 16; j++)
{
Buttons[j] = new Button();
this.Controls.Add(Buttons[j]);
if (j <= 3)
Buttons[j].Location = new System.Drawing.Point(10 + j * 65, 50);
else if (j > 3 && j <= 7)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 4) * 65, 80);
else if (j > 7 && j <= 11)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 8) * 65, 110);
else if (j > 11 && j <= 15)
Buttons[j].Location = new System.Drawing.Point(10 + (j - 12) * 65, 140);
Buttons[j].Size = new Size(60, 23);
}
for (int j = 0; j < 10; j++)
{
Buttons[j].Text = "" + j + "";
}
for (int j = 10; j < 11; j++)
{
Buttons[j].Text = ".";
}
for (int j = 11; j < 12; j++)
{
Buttons[j].Text = "=";
}
for (int j = 12; j < 13; j++)
{
Buttons[j].Text = "+";
}
for (int j = 13; j < 14; j++)
{
Buttons[j].Text = "-";
}
for (int j = 14; j < 15; j++)
{
Buttons[j].Text = "*";
}
for (int j = 15; j < 16; j++)
{
Buttons[j].Text = "/";
}
}
public void Buttons_Click(object sender, EventArgs e)
{
for (int j = 0; j < 10; ++j)
{
Buttons[j].Text = Convert.ToString( j );
for (int i = 1; i < 2; ++i)
{
j = Convert.ToInt16(textBoxes[i].Text);
textBoxes[i].Text=""+j;
}
}
// System.Windows.Forms.MessageBox.Show("You have clicked button " +
// ((System.Windows.Forms.Button)sender).Tag.ToString());
/*String tnum = sender.ToString();
int tlen = tnum.Length;
String no = tnum.Substring(tlen);
for (int j = 0; j < 16; j++)
{
if (Buttons[j].Text == no)
bno = j;
}
switch (bno)
{
case 0:
MessageBox.Show("0");
break;
case 1:
MessageBox.Show("1");
break;
case 2:
MessageBox.Show("2");
break;
case 3:
MessageBox.Show("3");
break;
case 4:
MessageBox.Show("4");
break;
case 5:
MessageBox.Show("5");
break;
case 6:
MessageBox.Show("6");
break;
case 7:
MessageBox.Show("7");
break;
case 8:
MessageBox.Show("8");
break;
case 9:
MessageBox.Show("9");
break;
case 10:
MessageBox.Show("10");
break;
case 11:
MessageBox.Show("11");
break;
case 12:
MessageBox.Show("12");
break;
case 13:
MessageBox.Show("13");
break;
case 14:
MessageBox.Show("14");
break;
case 15:
MessageBox.Show("15");
break;
}
*/
}
}
}
沒有留言:
張貼留言