In my winform app. I create on line a TableLayoutPanel , I add controls to the TableLayoutPanel, and then add the full TableLayoutPanel to a panel control.
My problem is that when there is need for vertical scrool bar, the horizental scroll bar is apearing eith no need.
How can I solve this?
Control ctrlToAddTo = this.panelOfObjects;
TableLayoutPanel tlp = new TableLayoutPanel();
tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
tlp.Width = this.Width-10;
tlp.Height = this.Height;
tlp.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
tlp.Padding = new Padding(0, 0, 0, 0);
foreach (PictureBox pb in listOfPb)
tlp.ColumnCount = (ctrlToAddTo.Width - 60) / (tlp.Controls.Width);
ctrlToAddTo.Width = (tlp.Controls.Width) * tlp.ColumnCount + 60;
tlp.Width = ctrlToAddTo.Width;
tlp.Height = ctrlToAddTo.Height;
tlp.AutoScroll = true;