2010年10月15日 星期五

3個矩陣

        System.Windows.Forms.TextBox[] TextBoxs;
        System.Windows.Forms.TextBox[] TextBoxs1;
        System.Windows.Forms.Button[] Buttons;




------------------------------------------------------------------------------


               TextBoxs = new System.Windows.Forms.TextBox[16];

               for (int i = 0; i < 16; ++i)
               {
                   TextBoxs[i] = new TextBox();
                   this.Controls.Add(TextBoxs[i]);
                   if (i <= 3)
                       TextBoxs[i].Location = new System.Drawing.Point(20 + i * 100, 30);

                   else if (i > 3 && i <= 7)
                       TextBoxs[i].Location = new System.Drawing.Point(20 + (i - 4) * 100, 60);
                   else if (i > 7 && i <= 11)
                       TextBoxs[i].Location = new System.Drawing.Point(20 + (i - 8) * 100, 90);
                   else if (i > 11 && i <= 15)
                       TextBoxs[i].Location = new System.Drawing.Point(20 + (i - 12) * 100, 120);
               }
                TextBoxs1 = new System.Windows.Forms.TextBox[16];

                for (int j = 0; j < 16; ++j)
                {
                    TextBoxs[j] = new TextBox();
                    this.Controls.Add(TextBoxs[j]);
                    if (j <= 3)
                        TextBoxs[j].Location = new System.Drawing.Point(500 + j * 100, 30);

                    else if (j > 3 && j <= 7)
                        TextBoxs[j].Location = new System.Drawing.Point(500 + (j - 4) * 100, 60);
                    else if (j > 7 && j <= 11)
                        TextBoxs[j].Location = new System.Drawing.Point(500 + (j - 8) * 100, 90);
                    else if (j > 11 && j <= 15)
                        TextBoxs[j].Location = new System.Drawing.Point(500 + (j - 12) * 100, 120);

                }

                Buttons = new System.Windows.Forms.Button[16];
       
                 for (int k = 0; k < 16; ++k)
              {
                Buttons[k] = new Button();
                this.Controls.Add(Buttons[k]);
                if (k <= 3)
                    Buttons[k].Location = new System.Drawing.Point(20 + k * 100, 200);
                else if (k > 3 && k <= 7)
                    Buttons[k].Location = new System.Drawing.Point(20 + (k - 4) * 100, 230);
                else if (k > 7 && k <= 11)
                    Buttons[k].Location = new System.Drawing.Point(20 + (k - 8) * 100, 260);
                else if (k > 11 && k <= 15)
                    Buttons[k].Location = new System.Drawing.Point(20 + (k - 12) * 100, 290);
            }

沒有留言:

張貼留言