简体   繁体   English

在tablelayout面板中动态添加控件

[英]dynamically adding controls in tablelayout panel

I have tablelayout panel with 6rows and 6 column in first cell ie 0,0 I want to add picturebox and in 0,1 I want add labels by using for loop howvto add picturebox and label alternatively or one below the other like pb label pb label 我在第一个单元格中有6行和6列的tablelayout面板,即0,0我想添加picturebox,而在0,1中我想通过使用for循环来添加标签howv交替添加picturebox和label或一个在另一个下方,如pb标签pb标签

plz help me 请帮我
all are dynamically I am not getting how to give the cordinates for placing control 一切都是动态的,我没有得到如何放置控制的坐标

Try this: 尝试这个:

Dim list As New List(Of Control)
Dim col, row, i As Integer

list.Add(pb1)
list.Add(lb1)
list.Add(pb2)
list.Add(lb2)
(....)
list.Add(pb6)
list.Add(lb6)

For row = 0 To 5
    For col = 0 To 5
        TableLayoutPanel1.Controls.Add(list(i), row, col)

        i += 1
    Next
Next

valter 瓦尔特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM