Programatically creating and fetching controls in TablelayoutPanel in - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Programatically creating and fetching controls in TablelayoutPanel in

elizaselizas Posts: 15Member
hi,
I have something to share with all.
Tablelayoutpanel can arrange the controls in the cells by defining the column and row number. We can add controls by defining the column and row Number.

Add a TableLayoutPanel control in the form and name it as "TablelayoutPnl".

Dim IDLbl As New Label
IDLbl.Name = "ID"
IDLbl.Size = New System.Drawing.Size(10, 17)
IDLbl.Text = "Test"
Dim IDpos As New TableLayoutPanelCellPosition(0, 0)
TablelayoutPnl.SetCellPosition(IDLbl, IDpos)
TablelayoutPnl.Controls.Add(IDLbl)

Dim NameTxt As New TextBox
NameTxt.Size = New System.Drawing.Size(100, 17)
NameTxt.Text = "Test Data"
Dim NamePos As New TableLayoutPanelCellPosition(1, 0)
TablelayoutPnl.SetCellPosition(NameTxt, NamePos)
TablelayoutPnl.Controls.Add(NameTxt)

Here one label and text box will be created in the first row in the first and second cell respectively.TableLayoutPanelCellPosition takes two parameters column and row. we can increase the row number in a for...loop if we want to create more number of rows

Thanks
[link=http://www.mindfiresolutions.com/programatically-creating-and-fetching-controls-in-tablelayoutpanel-in-windows-application-771.php]Eliza
[/link]
Sign In or Register to comment.