vb.net 以编程方式设置 colspan 和 rowspan 以在 tablelayoutpanel 中进行控制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21025340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 16:24:06  来源:igfitidea点击:

programmatically set colspan and rowspan for control in tablelayoutpanel

vb.net

提问by James Stafford

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

我似乎无法弄清楚如何在 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

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

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

回答by Bj?rn-Roger Kringsj?

You set ColumnSpanand RowSpanlike this:

你设置ColumnSpanRowSpan喜欢这样:

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