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

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.