以编程方式为tablelayoutpanel中的控件设置colspan和rowspan

时间:2014-01-09 16:10:07

标签: vb.net

我似乎无法弄清楚如何在vb.net中以编程方式设置colspan和rowspan 我有一个tablelayoutpanel,我编程添加标签,我能够添加标签,但我不能设置colspan和rowspan请帮助

    Dim lbl1 As Label = New Label()
    lbl1.AutoSize = False
    lbl1.BackColor = Color.Yellow
    lbl1.Text = newid
    lbl1.Height = 46
    lbl1.Width = 42
    TableLayoutPanel1.Controls.Add(lbl1, 1, 2) 'adds the label to column 1 row 1

我需要将colspan修改为4,将rowspan修改为2

1 个答案:

答案 0 :(得分:5)

您可以像这样设置ColumnSpanRowSpan

Me.TableLayoutPanel1.SetColumnSpan(lbl1, 4)
Me.TableLayoutPanel1.SetRowSpan(lbl1, 2)