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";
}
}
}
2010年11月11日 星期四
小算盤基本版
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
int x,y,z;
Boolean a = false;
Boolean b = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "";
button1.Text = "0";
button2.Text = "00";
button3.Text = "=";
button4.Text = "1";
button5.Text = "2";
button6.Text = "3";
button7.Text = "4";
button8.Text = "5";
button9.Text = "6";
button10.Text = "7";
button11.Text = "8";
button12.Text = "9";
button13.Text = "+";
button14.Text = "-";
button15.Text = "*";
button16.Text = "/";
}
private void button1_Click(object sender, EventArgs e)
{
if (a == false)
{
}
else
{
textBox1.Text += 0;
}
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += 1;
a = true;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += 2;
a = true;
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += 3;
a = true;
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text += 4;
a = true;
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += 5;
a = true;
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += 6;
a = true;
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += 7;
a = true;
}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text += 8;
a = true;
}
private void button12_Click(object sender, EventArgs e)
{
textBox1.Text += 9;
a = true;
}
private void button16_Click(object sender, EventArgs e)
{
if (b == true)
{
}
else
{
x = int.Parse(textBox1.Text);
textBox1.Text = "";
a = false;
b = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (a == true & b == true)
{
y = int.Parse(textBox1.Text);
z = x / y;
textBox1.Text=""+z;
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int x,y,z;
Boolean a = false;
Boolean b = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "";
button1.Text = "0";
button2.Text = "00";
button3.Text = "=";
button4.Text = "1";
button5.Text = "2";
button6.Text = "3";
button7.Text = "4";
button8.Text = "5";
button9.Text = "6";
button10.Text = "7";
button11.Text = "8";
button12.Text = "9";
button13.Text = "+";
button14.Text = "-";
button15.Text = "*";
button16.Text = "/";
}
private void button1_Click(object sender, EventArgs e)
{
if (a == false)
{
}
else
{
textBox1.Text += 0;
}
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += 1;
a = true;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += 2;
a = true;
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += 3;
a = true;
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text += 4;
a = true;
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += 5;
a = true;
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += 6;
a = true;
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += 7;
a = true;
}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text += 8;
a = true;
}
private void button12_Click(object sender, EventArgs e)
{
textBox1.Text += 9;
a = true;
}
private void button16_Click(object sender, EventArgs e)
{
if (b == true)
{
}
else
{
x = int.Parse(textBox1.Text);
textBox1.Text = "";
a = false;
b = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (a == true & b == true)
{
y = int.Parse(textBox1.Text);
z = x / y;
textBox1.Text=""+z;
}
}
}
}
2010年11月5日 星期五
井字遊戲
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;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Buttons = new System.Windows.Forms.Button[9];
//Buttons[i].Size=new Size(50,50);
for (int i = 0; i < 9; ++i)
{
Buttons[i] = new Button();
Buttons[i].Click += new System.EventHandler(Buttons_Click);
this.Controls.Add(Buttons[i]);
if (i <= 2)
Buttons[i].Location = new System.Drawing.Point(10 + i * 100, 10);
else if (i > 2 && i <= 5)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 3) * 100, 40);
else if (i > 5 && i <= 9)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 6) * 100, 70);
}
}
public void Buttons_Click(object sender, EventArgs e)
{
int bno = 0;
int i = 0;
Buttons[i].Text = Buttons[bno].Text;
bno = i;
switch (bno)
{
case 0:
Buttons[0].Image = pictureBox2.Image;
break;
case 1:
Buttons[1].Image = pictureBox2.Image;
break;
case 2:
Buttons[2].Image = pictureBox2.Image;
break;
case 3:
Buttons[3].Image = pictureBox2.Image;
break;
case 4:
Buttons[4].Image = pictureBox2.Image;
break;
case 5:
Buttons[5].Image = pictureBox2.Image;
break;
case 6:
Buttons[6].Image = pictureBox2.Image;
break;
case 7:
Buttons[7].Image = pictureBox2.Image;
break;
case 8:
Buttons[8].Image = pictureBox2.Image;
break;
}
}
private void button1_Click(object sender, EventArgs e)
{
Random Rd = new Random();
int Rdno = Rd.Next(9);
label1.Text = "" + Rdno;
Buttons[Rdno].Image =pictureBox1.Image;
}
}
}
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;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Buttons = new System.Windows.Forms.Button[9];
//Buttons[i].Size=new Size(50,50);
for (int i = 0; i < 9; ++i)
{
Buttons[i] = new Button();
Buttons[i].Click += new System.EventHandler(Buttons_Click);
this.Controls.Add(Buttons[i]);
if (i <= 2)
Buttons[i].Location = new System.Drawing.Point(10 + i * 100, 10);
else if (i > 2 && i <= 5)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 3) * 100, 40);
else if (i > 5 && i <= 9)
Buttons[i].Location = new System.Drawing.Point(10 + (i - 6) * 100, 70);
}
}
public void Buttons_Click(object sender, EventArgs e)
{
int bno = 0;
int i = 0;
Buttons[i].Text = Buttons[bno].Text;
bno = i;
switch (bno)
{
case 0:
Buttons[0].Image = pictureBox2.Image;
break;
case 1:
Buttons[1].Image = pictureBox2.Image;
break;
case 2:
Buttons[2].Image = pictureBox2.Image;
break;
case 3:
Buttons[3].Image = pictureBox2.Image;
break;
case 4:
Buttons[4].Image = pictureBox2.Image;
break;
case 5:
Buttons[5].Image = pictureBox2.Image;
break;
case 6:
Buttons[6].Image = pictureBox2.Image;
break;
case 7:
Buttons[7].Image = pictureBox2.Image;
break;
case 8:
Buttons[8].Image = pictureBox2.Image;
break;
}
}
private void button1_Click(object sender, EventArgs e)
{
Random Rd = new Random();
int Rdno = Rd.Next(9);
label1.Text = "" + Rdno;
Buttons[Rdno].Image =pictureBox1.Image;
}
}
}
2010年11月4日 星期四
4x4矩陣試做版
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
System.Windows.Forms.TextBox[] TextBoxes;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TextBoxes = new System.Windows.Forms.TextBox[46];
for (int i = 1; i <= 16; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 4)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 1) * 106, 12);
else if (i > 4 && i <= 8)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 5) * 106, 40);
else if (i > 8 && i <= 12)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 9) * 106, 68);
else if (i > 12 && i <= 16)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 13) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 17; i <= 33; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 20)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 17) * 106, 12);
else if (i > 20 && i <= 24)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 21) * 106, 40);
else if (i > 24 && i <= 28)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 25) * 106, 68);
else if (i > 28 && i <= 32)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 29) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 34; i <= 48; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 37)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 33) * 106, 512);
else if (i > 37 && i <= 41)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 37) * 106, 540);
else if (i > 41 && i <= 45)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 41) * 106, 568);
else if (i > 45 && i <= 48)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 45) * 106, 596);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
System.Windows.Forms.TextBox[] TextBoxes;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TextBoxes = new System.Windows.Forms.TextBox[46];
for (int i = 1; i <= 16; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 4)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 1) * 106, 12);
else if (i > 4 && i <= 8)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 5) * 106, 40);
else if (i > 8 && i <= 12)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 9) * 106, 68);
else if (i > 12 && i <= 16)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 13) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 17; i <= 33; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 20)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 17) * 106, 12);
else if (i > 20 && i <= 24)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 21) * 106, 40);
else if (i > 24 && i <= 28)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 25) * 106, 68);
else if (i > 28 && i <= 32)
TextBoxes[i].Location = new System.Drawing.Point(500 + (i - 29) * 106, 96);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
for (int i = 34; i <= 48; ++i)
{
TextBoxes[i] = new TextBox();
this.Controls.Add(TextBoxes[i]);
if (i <= 37)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 33) * 106, 512);
else if (i > 37 && i <= 41)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 37) * 106, 540);
else if (i > 41 && i <= 45)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 41) * 106, 568);
else if (i > 45 && i <= 48)
TextBoxes[i].Location = new System.Drawing.Point(12 + (i - 45) * 106, 596);
//產生出16個TextBox,並排列整齊成為4x4的空格方陣
}
}
}
}
訂閱:
文章 (Atom)