Results 1 to 4 of 4

Thread: [RESOLVED] TableLayoutPanel problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    185

    Resolved [RESOLVED] TableLayoutPanel problem

    Ok, it's the first time I try to use this control, and I can't figure this out.

    Problems:
    1. How to get 0 padding/inner margin in the cells? I want just the border as a colored line at the next close pixel to the control in the cell. Or if border set to none, I want the controls with no gap.
    2. How do I actually add/remove rows& columns? I thought this was by setting the .ColumnCount property, but if I set it to 3, and then try to access the third column, it gives exception, so it's obviously just two columns, although it also looks like 3 on the form. ? I created it in designer with 2 columns though. But I don't understand how this hangs together..

    plz.. ?

    http://i54.tinypic.com/2nitpo4.png

    Code:
     Dim z0, z1, z2 As New ZedGraphControl
            z0.Dock = DockStyle.Fill
            z1.Dock = DockStyle.Fill
            z2.Dock = DockStyle.Fill
            z0.Padding = New Padding(0)
            z1.Padding = New Padding(0)
            z2.Padding = New Padding(0)
    
    
            tlpTest.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single
            tlpTest.AutoSize = True
            tlpTest.Padding = New Padding(0)
            tlpTest.Margin = New Padding(0)
    
    
            tlpTest.ColumnCount = 1
            tlpTest.Controls.Add(z0, 0, 0)
            tlpTest.ColumnCount = 2
            tlpTest.Controls.Add(z1, 1, 0)
            tlpTest.ColumnCount = 3
            tlpTest.Controls.Add(z2, 2, 0)
    
    
            tlpTest.ColumnStyles.Item(0).SizeType = SizeType.Percent
            tlpTest.ColumnStyles.Item(0).Width = 33
            tlpTest.ColumnStyles.Item(1).SizeType = SizeType.Percent
            tlpTest.ColumnStyles.Item(1).Width = 33
            'tlpTest.ColumnStyles.Item(2).SizeType = SizeType.Percent
            'tlpTest.ColumnStyles.Item(2).Width = 33

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    185

    Re: TableLayoutPanel problem

    ai.. how silly.. i forgot to add below.. Well, that leaves only one question then..
    Code:
            z0.Margin = New Padding(0)
            z1.Margin = New Padding(0)
            z2.Margin = New Padding(0)

  3. #3
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: TableLayoutPanel problem

    I just added a TableLayoutPanel to my Form, I then went into the designer file to view the code, this is what I see:

    vb.net Code:
    1. '
    2.         'TableLayoutPanel1
    3.         '
    4.         Me.TableLayoutPanel1.ColumnCount = 2
    5.         Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    6.         Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    7.         Me.TableLayoutPanel1.Location = New System.Drawing.Point(280, 344)
    8.         Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
    9.         Me.TableLayoutPanel1.RowCount = 2
    10.         Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    11.         Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
    12.         Me.TableLayoutPanel1.Size = New System.Drawing.Size(200, 100)
    13.         Me.TableLayoutPanel1.TabIndex = 4

    That is how it will be done. Sometimes you can use the designer code to get information on how to code controls.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    185

    Re: TableLayoutPanel problem

    Ah.. smart. I never thought about looking at that file..

    Now I see; It shows I need to add the columnstyle for each column I add. Maybe that's normal for all styles too, idk.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width