1

I have a TableLayoutPanel that has several TableLayoutPanels inside it. The amount changes dynamically and will almost always be too many to be able to fit inside the form.I need it to have a scroll bar so I can view the entire component.

I have tried setting the autoscroll property on the main panel to true and docking it and/or setting a maximum size. What the controler does instead, is to try and fit ALL of the Panel inside the form therefore changing the size of its inside components and squeezing them all together instead of creating a scroll bar to scroll through my Panel.

Do you guys know what I might be doing wrong?

Thanks.

Jose

PS: I am using VS 2010

José
  • 19
  • 1
  • 2
  • TLP doesn't have an exposed AutoScroll property. You can set its AutoScrollMinSize property to force it to display a scrollbar when it gets too small. – Hans Passant Jun 15 '11 at 09:37
  • I tried that and it didnt work. Im still stuck :S – José Jun 16 '11 at 08:46
  • See my sample code from [here][1], not sure which property is that you need. [1]: http://stackoverflow.com/a/17722307/1677041 – Itachi Jul 18 '13 at 11:41
  • Try this solution : https://stackoverflow.com/questions/15620454/tablelayoutpanel-displays-vertical-scroll/25601129#25601129 – Bioukh Nov 27 '19 at 19:17

5 Answers5

2

I had the same issue one day and found out that the problem was that I had a "MinimumSize" set to the TableLayoutPanel. That caused the control to keep a minimum height no matter what the Dock and/or Anchor constraints, preventing the AutoScroll feature to work properly. Since that feature is based on a simple check on the Y coordinates of all children controls of a control against that control's height, the scrollbar was not appearing despite the fact the the TableLayoutPanel's child controls were "disapearing" out of sight due to its parent control clip area.

So in other words, check the MinimumSize property of TableLayoutPanel and make sure it's empty.

1

Late answer, but I've been fighting with a complex layout recently and was looking for a solution to get my scrolling working on a screen with far too many fields. Honestly, better design should avoid this problem 99% of the time but sometimes your hands are just tied.

The Problem

The problem seems to be that if you're nested too deeply with multiple grids, groups, and panels they stop reporting properly to parent controls that their contents have overflown the size of the current screen. Actually, the problem is probably that the controls are all set to dock fill and do fit within their parent control, so the top level control doesn't know that the contents of its great-great-great-great-grandchild controls don't fit.

Solution

The trick to fix this seems to be manually forcing the top most panel to scroll at a certain minimum size:

MainPanel.AutoSize = true;
MainPanel.AutoScrollMinSize = new Size(400, 500);
JoelC
  • 3,664
  • 9
  • 33
  • 38
1

Maybe this will help.

if it still doesn't work, try put a panel and then put the tableLayoutPanel into that panel. Set to true the autoScroll property of the panel.

Community
  • 1
  • 1
Samidjo
  • 2,315
  • 30
  • 37
  • I had already seen the link you sent me, and about your suggestion, I tried it and it didn't work, it just gave the same result.. – José Jun 16 '11 at 08:47
1

I had the same thing happen on my project. All my controls were squished inside the TableLayoutPanel. In my case, I was rendering many of the controls as ColumnStyle.Percent. Switching this to ColumnStyle.Autosize was the fix I needed.

I assume you've set these properties as well, but just in case my TableLayoutPanels also use the following settings:

AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
AutoScroll = true;
bsegraves
  • 980
  • 13
  • 22
0

TableLayoutPanel scrolling is full of bugs. The solution to make it work correctly is here.

Bioukh
  • 1,888
  • 1
  • 16
  • 27