James Stafford
James Stafford

Reputation: 1054

programmatically set colspan and rowspan for control in tablelayoutpanel

I can not seem to figure out how to set colspan and rowspan programatically in vb.net I have a tablelayoutpanel which I am programattically adding a label to I am able to add the label but I can not set the colspan and rowspan please help

    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

I need to modify the colspan to 4 and rowspan to 2

Upvotes: 2

Views: 8458

Answers (1)

You set ColumnSpan and RowSpan like this:

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

Upvotes: 7

Related Questions