[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
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)
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:
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.ColumnCount = 2
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Location = New System.Drawing.Point(280, 344)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 2
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(200, 100)
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.
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!