c#怎样在winform窗体中自动生成label1控件,比如有姓名,性别,年龄三个字段就自动生成三个label来显示
2013-11-12
展开全部
private void button1_Click(object sender, EventArgs e)
{
var list = new List<string> { "张三", "李四", "王五" };
for (int i = 0; i < list.Count; i++)
{
Label lb = new Label();
lb.AutoSize = true;
lb.Location = new System.Drawing.Point((53 + i * 60), 73);
lb.Name = "label1";
lb.Size = new System.Drawing.Size(41, 12);
lb.TabIndex = i;
lb.Text = list[i];
this.Controls.Add(lb);
} }
{
var list = new List<string> { "张三", "李四", "王五" };
for (int i = 0; i < list.Count; i++)
{
Label lb = new Label();
lb.AutoSize = true;
lb.Location = new System.Drawing.Point((53 + i * 60), 73);
lb.Name = "label1";
lb.Size = new System.Drawing.Size(41, 12);
lb.TabIndex = i;
lb.Text = list[i];
this.Controls.Add(lb);
} }
2013-11-12
展开全部
lb.Location = new System.Drawing.Point(73, (53 + i * 60));
把 i 那个变量的 写到 y 参数就OK
把 i 那个变量的 写到 y 参数就OK
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询