sennekeennes

Hello,

I'm trying to create a tablelayoutpanel and to add some items to it.
This is my code:

Dim tabel As TableLayoutPanel

Sub tekenen()

       'Tabel
        tabel = New TableLayoutPanel
        tabel.Location = New System.Drawing.Point(30, 100)


        tabel.ColumnStyles.Clear()
        tabel.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, My.Computer.Screen.WorkingArea.Width - 180 - 300 - 30)) 
        tabel.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 300)) 
        tabel.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 90))       
        tabel.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 90))

        tabel.RowStyles.Clear()
        For i As Integer = 0 To aantalspelers - 1 'Consider 'aantalspelers' > 1
            tabel.RowStyles.Add(New ColumnStyle(SizeType.Absolute, 75))

            Dim label As New Label
            Dim font As New Font("Tahoma", 10, FontStyle.Regular, GraphicsUnit.Pixel)
            label.Font = font
            label.Text = namen(i)
            tabel.Controls.Add(label, 1, i)

        Next

        Controls.Add(tabel)

End Sub

 

This code doesn't work, it only shows a small, gray panel.

Help!



Re: Windows Forms General problem with adding controls to a tablelayoutpanel

Keith Rome

Your panel is too small to see the controls (they are being clipped). Enable AutoSize on the panel:

tabel.AutoSize = True

Also, you are placing the Label into the second column of the table (zero-based column array)... not sure if you are aware of that.

HTH






Re: Windows Forms General problem with adding controls to a tablelayoutpanel

sennekeennes

Thanks!<br />It works now.