I have created a flowlayoutpanel that renders panels inside on it for navigation pruposes. Now, I am doing the add of elements programmatically do reduce slow of VB 2012 application on editing codes. But then, I have an unexpected result on adding a new panel on my flowlayoutpanel.
Here is my code on creating the new panel:
Dim AppPanel As New Panel
Dim AppTableLayoutPanel As New TableLayoutPanel
Dim RecordCountPanel As New Panel
Dim RecordCountLabel As New Label
Dim RecordNameLabel As New Label
Dim AddButton As New Button
AppPanel.Width = 259
AppPanel.Height = 43
AppPanel.Margin = New Padding(0, 0, 0, 5)
AppPanel.BackColor = SystemColors.InactiveBorder
RecordCountPanel.BackColor = Color.SteelBlue
RecordCountPanel.Margin = New Padding(0)
RecordCountPanel.Dock = DockStyle.Fill
RecordCountLabel.Anchor = System.Windows.Forms.AnchorStyles.Left
RecordCountLabel.Text = "245" '
RecordCountLabel.Width = 70
RecordCountLabel.Height = 42
RecordCountLabel.Padding = New Padding(0, 6, 0, 0)
RecordCountLabel.TextAlign = ContentAlignment.MiddleCenter
RecordCountLabel.Font = New Font("Microsoft Sans Serif", 12)
RecordCountLabel.ForeColor = Color.White
'RecordCountLabel.BackColor = Color.Orange
RecordCountLabel.Location.X.Equals(4)
RecordCountLabel.Location.Y.Equals(12)
AppTableLayoutPanel.Dock = DockStyle.Fill
AppTableLayoutPanel.ColumnCount = 3
AppTableLayoutPanel.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 33.18F))
AppTableLayoutPanel.Controls.Add(RecordCountPanel, 0, 0)
AddButton.Dock = DockStyle.Fill
AddButton.Font = New Font("Microsoft Sans Serif", 14)
AddButton.Text = "+"
RecordNameLabel.Anchor = System.Windows.Forms.AnchorStyles.Left
RecordNameLabel.Text = "Request Item Logs"
RecordNameLabel.Width = 150
RecordNameLabel.Height = 42
RecordNameLabel.Padding = New Padding(0, 6, 0, 0)
RecordNameLabel.TextAlign = ContentAlignment.MiddleLeft
RecordNameLabel.Font = New Font("Microsoft Sans Serif", 10)
AppTableLayoutPanel.ColumnStyles.Add(New ColumnStyle(SizeType.Percent, 66.82F))
AppTableLayoutPanel.Controls.Add(RecordNameLabel, 1, 0)
AppTableLayoutPanel.ColumnStyles.Add(New ColumnStyle(SizeType.Absolute, 53.0F))
AppTableLayoutPanel.Controls.Add(AddButton, 2, 0)
RecordCountPanel.Controls.Add(RecordCountLabel)
AppPanel.Controls.Add(AppTableLayoutPanel)
Main.FlowlayoutPanel.Controls.Add(AppPanel)
- The text on the 2nd column is not showing
- The button on the 3rd column shows unusual
In Addition:
If I remove AppTableLayoutPanel.Controls.Add(RecordCountPanel, 0, 0)
, the other elements will be rendered normally.