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 Button1;
int width, height;
int i, j,c;
Button[,] Buttons = new Button[10, 10];
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

for( i=1; i<10;i++)
{
for (j = 1; j < 10; j++)
{
Buttons[i, j] = new Button();
this.Controls.Add(Buttons[i, j]);
Buttons[i, j].Location = new Point(i * 66, j * 75);
width = this.Size.Width;
height = this.Size.Height;
width /= 11;
height /=11;
Buttons[i,j].Size = new Size(width, height);
c = i * j;
Buttons[i, j].Text = Convert.ToString(c);


}
}
}
}
}


hungtim20 發表在 痞客邦 留言(0) 人氣()

  • Nov 28 Fri 2014 13:02
  • 11.14

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 _123
{
   public partial class Form1 : Form
   {
       //System.Windows.Forms.Button Button1;
       Button[,] Buttons = new Button[9, 9];
       int width, height;
       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_Load(object sender, EventArgs e)
       {
           
           for (int i = 0; i < 9; i++)
           {
               for (int j = 0; j < 9; j++)
               {
                   
                   Buttons[i, j] = new Button();
                   
                   width = this.Size.Width;
                   height = this.Size.Height;
                   width /= 10;
                   height /= 5;
                   Buttons[i, j].Size = new Size(width, height);
                   this.Controls.Add(Buttons[i, j]);
                   Buttons[i, j].Location = new Point(i * 80, j *100 );
               }
           }


           //Button1 = new System.Windows.Forms.Button();

           //Button1.Location = new Point(100, 100);
           //this.Controls.Add(Button1);
           //Button1.Click += new System.EventHandler(this.Button1_Click);

           //Button[] btuArray = new Button[3];
       }

       private void Button1_Click(object sender, EventArgs e)
       {
           //MessageBox.Show("HELLO");
       }

       private void button1_Click_1(object sender, EventArgs e)
       {

       }
   }
}


hungtim20 發表在 痞客邦 留言(0) 人氣()

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 i = 0;
       public Form1()
       {
           InitializeComponent();
       }
       private void Form1_Load(object sender, EventArgs e)
       {
           button1.Text = "";
           button2.Text = "";
           button3.Text = "";
           button4.Text = "";
           button5.Text = "";
           button6.Text = "";
           button7.Text = "";
           button8.Text = "";
           button9.Text = "";
       }

       private void button1_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button1.Text = "O";
           }
           if (i % 2 == 1)
           {
               button1.Text = "X";
           }
           i = i + 1;
           button1.Enabled = false;

       }

       private void button2_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button2.Text = "O";
           }
           if (i % 2 == 1)
           {
               button2.Text = "X";
           }
           i = i + 1;
           button2.Enabled = false;
       }

       private void button3_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button3.Text = "O";
           }
           if (i % 2 == 1)
           {
               button3.Text = "X";
           }
           i = i + 1;
           button3.Enabled = false;
       }

       private void button4_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button4.Text = "O";
           }
           if (i % 2 == 1)
           {
               button4.Text = "X";
           }
           i = i + 1;
           button4.Enabled = false;
       }

       private void button5_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button5.Text = "O";
           }
           if (i % 2 == 1)
           {
               button5.Text = "X";
           }
           i = i + 1;
           button5.Enabled = false;
       }

       private void button6_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button6.Text = "O";
           }
           if (i % 2 == 1)
           {
               button6.Text = "X";
           }
           i = i + 1;
           button6.Enabled = false;
       }

       private void button7_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button7.Text = "O";
           }
           if (i % 2 == 1)
           {
               button7.Text = "X";
           }
           i = i + 1;
           button7.Enabled = false;
       }

       private void button8_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button8.Text = "O";
           }
           if (i % 2 == 1)
           {
               button8.Text = "X";
           }
           i = i + 1;
           button8.Enabled = false;
       }

       private void button9_Click(object sender, EventArgs e)
       {
           if (i % 2 == 0)
           {
               button9.Text = "O";
           }
           if (i % 2 == 1)
           {
               button9.Text = "X";
           }
           i = i + 1;
           button9.Enabled = false;

       }

      
   }
}


hungtim20 發表在 痞客邦 留言(0) 人氣()

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;
using System.Threading;

namespace WindowsFormsApplication1
{
   public partial class Form1 : Form
   {
       int ssum1 = 0;
       int ssum2 = 0;
       public Form1()
       {
           InitializeComponent();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           int d1, d2 , dsum;
           Random irand = new Random();
           d1 = irand.Next(1, 7);
           d2 = irand.Next(1, 7);
           label1.Text=Convert.ToString(d1);
           label2.Text=Convert.ToString(d2);
           dsum = d1 + d2;
           for (int i = 1; i <= dsum; i++)
           {
               button2.Left = (i+ssum1)*5;
               Thread.Sleep(100); // Delay 0.1秒
               Application.DoEvents();
           }
           ssum1 = ssum1 + dsum;
           textBox1.Text = Convert.ToString(ssum1);
           if (button2.Left >= 100)
               MessageBox.Show("2 win");

       }

       private void button3_Click(object sender, EventArgs e)
       {
           int d1, d2, dsum;
           Random irand = new Random();
           d1 = irand.Next(1, 7);
           d2 = irand.Next(1, 7);
           label1.Text = Convert.ToString(d1);
           label2.Text = Convert.ToString(d2);
           dsum = d1 + d2;
           for (int i = 1; i <= dsum; i++)
           {
               button4.Left = (i + ssum2) * 5;
               Thread.Sleep(100); // Delay 0.1秒
               Application.DoEvents();
           }
           ssum2 = ssum2 + dsum;
           textBox2.Text = Convert.ToString(ssum2);
           if (button4.Left >= 100)
               MessageBox.Show("4 win");

       }
   }
}


hungtim20 發表在 痞客邦 留言(0) 人氣()

«12