菜鸟求教WinForm在panel中添加控件的问题。。。

2024-11-06 23:33:02
推荐回答(5个)
回答(1):

//写个例子给你,你自己看一下
int top = 10;
int left = 10;
for (int i = 1; i < 10; i++)
{
Label lblTitle = new Label();
lblTitle.Name = "lblTitle" + i.ToString();
lblTitle.Text = lblTitle.Name;
lblTitle.Left = left;
lblTitle.Top =i*(top+lblTitle.Height);
pnl.Controls.Add(lblTitle);
}

回答(2):

//写个例子给你,你自己看一下
int
top
=
10;
int
left
=
10;
for
(int
i
=
1;
i
<
10;
i++)
{
Label
lblTitle
=
new
Label();
lblTitle.Name
=
"lblTitle"
+
i.ToString();
lblTitle.Text
=
lblTitle.Name;
lblTitle.Left
=
left;
lblTitle.Top
=i*(top+lblTitle.Height);
pnl.Controls.Add(lblTitle);
}

回答(3):

你添加的时候,要设定动态设定他的位置的啊inkbabel.Location= new point(x,y),xy是你计算出来的位置值

回答(4):

linkbabel.Location = new System.Drawing.Point(33,44);
33、44为LinkLabel相对于panel容器的坐标。

回答(5):

没有指定location