tonelm54
asked on
Creating a TablePanelLayout in run-time
Im trying to create a TablePanelLayout during run-time, and add 2 link buttons to it, but I keep getting errors about the coloum number not been valid
Any ideas what Im doing wrong?
Any ideas what Im doing wrong?
Dim newTableLayout As New TableLayoutPanel
newTableLayout.RowCount = 4
newTableLayout.ColumnCount = 2
newTableLayout.ColumnStyles(0).SizeType = SizeType.Absolute
newTableLayout.ColumnStyles(0).Width = 20
newTableLayout.ColumnStyles(1).SizeType = SizeType.AutoSize
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Text = " "
newLabel1.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Add(newLabel1, 0, 0)
newTableLayout.Controls.Add(newLabel1, 0, 1)
On which line do you get an error?
Dim newTableLayout As New TableLayoutPanel
newTableLayout.RowCount = 4
newTableLayout.ColumnCount = 2
newTableLayout.ColumnStyle s(0).SizeT ype = SizeType.Absolute ' not sure about
newTableLayout.ColumnStyle s(0).Width = 20 ' this three
newTableLayout.ColumnStyle s(1).SizeT ype = SizeType.AutoSize ' lines here.
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad d(newLabel 1, 0, 0)
newTableLayout.Controls.Ad d(newLabel 2, 0, 1)
Me.Controls.Add(newTableLa yout)
Dim newTableLayout As New TableLayoutPanel
newTableLayout.RowCount = 4
newTableLayout.ColumnCount
newTableLayout.ColumnStyle
newTableLayout.ColumnStyle
newTableLayout.ColumnStyle
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad
newTableLayout.Controls.Ad
Me.Controls.Add(newTableLa
Also I think you need to specify
newTableLayout.Location = new Point(10, 40)
newTableLayout.Size = new Size(200, 200)
Ashok
newTableLayout.Location = new Point(10, 40)
newTableLayout.Size = new Size(200, 200)
Ashok
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would suggest you place TableLayoutpanel named "newTableLayout" at Design time in the form. It would save lot of headache.
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Size = new Size(125, 18)
newLabel2.Size = new Size(125, 18)
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad d(newLabel 1, 0, 0) ' col, row
newTableLayout.Controls.Ad d(newLabel 2, 1, 2)
Me.Controls.Add(newTableLa yout)
HTH
Ashok
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Size = new Size(125, 18)
newLabel2.Size = new Size(125, 18)
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad
newTableLayout.Controls.Ad
Me.Controls.Add(newTableLa
HTH
Ashok
Sorry, you do not need to add using "Me.Controls.Add(newTableL ayout)".
I would suggest you place TableLayoutpanel named "newTableLayout" at Design time in the form. It would save lot of headache.
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Size = new Size(125, 18)
newLabel2.Size = new Size(125, 18)
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad d(newLabel 1, 0, 0) ' col, row
newTableLayout.Controls.Ad d(newLabel 2, 1, 2)
HTH
Ashok
I would suggest you place TableLayoutpanel named "newTableLayout" at Design time in the form. It would save lot of headache.
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Size = new Size(125, 18)
newLabel2.Size = new Size(125, 18)
newLabel1.Text = " "
newLabel2.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad
newTableLayout.Controls.Ad
HTH
Ashok
newTableLayout.RowCount = 4
newTableLayout.ColumnCount
newTableLayout.ColumnStyle
newTableLayout.ColumnStyle
newTableLayout.ColumnStyle
Dim newLabel1 As New LinkLabel
Dim newLabel2 As New LinkLabel
newLabel1.Text = " "
newLabel1.Text = "+"
AddHandler newLabel1.Click, AddressOf clickButton
AddHandler newLabel2.Click, AddressOf clickButton
newTableLayout.Controls.Ad
newTableLayout.Controls.Ad
HTH
Ashok