Hi, Consider you want to add a label inside of a table layout panel programmatically after pressing a button and it gets the value of current pressedcounts. Here's the approach (IT MIGHT BE NOT A GOOD IDEA AND NOT THE BEST WAY BUT IT WORKS):
Code:
Public Class Form1
    Public i As Integer = 0
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        i += 1
        TableLayoutPanel1.Controls.Add(New Label, 0, 0)
        TableLayoutPanel1.Controls.Item(i - 1).Text = i.ToString
    End Sub
End Class
- The problem is you may access only to few properties of added control like "text". I even made a UserControl and added it but still not able to access things like "dock", "textorientation", "autosize".
- It would be better if all new added columns be 50% in size and decent.
- I remember jmcilhinney mentioned something about "TryCast" thing in another similar thread but I'm not familiar with it, plus Learn.Microsoft says something about expression ctype and stuffs which is confusing... :'(

As a visual example the goal is to add controls in order of occurrence in rows and columns from left to right all middle oriented docked top and bottom with bold and regular properties but programmatically...
Name:  tablelayoutexample.png
Views: 2509
Size:  6.3 KB