close

使用二維陣列的方式寫出按扭矩陣

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 WindowsFormsApplication8
{
public partial class Form1 : Form
{
//System.Windows.Forms.Button Button1;
//Button[,] Buttons;
Button[,] buttons = new Button[9, 9];

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
//int rows = buttons.GetUpperBound(0) + 1; // Getting the number of rows in the array
//int columns = buttons.GetUpperBound(buttons.Rank - 1) + 1; // Getting the number of columns in the array

// Instantiating all the buttons in the array
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(buttons[i, j]);
}
}

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

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

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

 

}
}

arrow
arrow
    全站熱搜

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