Windows Develop Bookmark and Share   
 index > Windows Forms General > problem with adding controls to a tablelayoutpanel
 

problem with adding controls to a tablelayoutpanel

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!

sennekeennes  Sunday, December 10, 2006 7:06 PM

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

Keith Rome  Wednesday, December 13, 2006 3:56 AM

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

Keith Rome  Wednesday, December 13, 2006 3:56 AM
Thanks!<br />It works now.
sennekeennes  Wednesday, December 13, 2006 4:15 PM

You can use google to search for other answers

Custom Search

More Threads

• WM_NCCALCSIZE and size problem when window restores
• Disk Serial Number
• Hibernate and Stand by
• Form Count
• Disable window
• Load event doesn't fire
• Datasource problem on mdi form save button click
• DataGridViewTextBoxColumn bounded to child table
• To display Node atrributes such that node name added to tree?
• Annotations in a Richtextbox or another way to add some invisible informations