こんにちは、私がここに投稿した写真に似たカスタムメイドのフレームを作成する方法を誰かに教えてもらえますか。フレームは、フレームに配置されたボタンに基づいてサイズを変更できる必要があります。
アップロードされた写真はより良いアイデアを与えるかもしれません、私はそれに似たものを作りたいです。では、このようなフレームをWindowsフォームで作成するにはどうすればよいでしょうか。
私のコード:
private void button1_Click(object sender、EventArgs e){
int start_x = Convert.ToInt32(textbox1.Text);
int start_y = Convert.ToInt32(textbox2.Text);
//Clear out the existing controls, we are generating a new table layout
tableLayoutPanel1.Controls.Clear();
//Clear out the existing row and column styles
tableLayoutPanel1.ColumnStyles.Clear();
tableLayoutPanel1.RowStyles.Clear();
//Now we will generate the table, setting up the row and column counts first
tableLayoutPanel1.ColumnCount = start_x;
tableLayoutPanel1.RowCount = start_y;
for (int x = 0; x < start_x; x++)
{
//First add a column
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
for (int y = 0; y < start_y; y++)
{
//Next, add a row. Only do this when once, when creating the first column
if (x == 0)
{
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
}
//Create the control, in this case we will add a button
Button cmd = new Button();
cmd.Width = 120;
cmd.Height = 60;
cmd.BackColor = Color.LightGreen;
cmd.FlatStyle = FlatStyle.Popup;
cmd.Text = string.Format("ds");
cmd.Click += new EventHandler(this.btnDynamicButton_Click);
//Finally, add the control to the correct location in the table
tableLayoutPanel1.Controls.Add(cmd, x, y);
}
しかし、そのフレームを作成してそれに応じて配置する方法がわかりません。