| ■No83798 (Users さん) に返信 > Formロード時に9列×10行=計90個のTextboxを表示したいのですが、 「90 個の TextBox」の代わりに、9列10行な 「1個の DataGridView」でまかなえないでしょうか?
> 下記のような9列×1行までしかうまく対応出来ていません。行を増やすにはどうしたら良いでしょうか? > this.testTextBox[i].Location = new Point(i * 30, 10);
X 座標は「i * 30」という変動値なのに、 Y 座標が「10」という固定値だからでしょう。
this.testTextBox = new System.Windows.Forms.TextBox[90]; this.SuspendLayout();
for (int y = 0; y < 10; y++) for (int x = 0; x < 9; x++) { int i = y * 9 + x; this.testTextBox[i] = new System.Windows.Forms.TextBox(); this.testTextBox[i].Name = "textTextBox" + i; this.testTextBox[i].Text = y + ":" + x; this.testTextBox[i].Size = new Size(30, 20); this.testTextBox[i].Location = new Point(x * 30, y * 20); } this.Controls.AddRange(this.testTextBox); this.ResumeLayout(false); |