1

I have a panel with AutoScroll = false and AutoSize = false which contains a TableLayoutPanel docked to it as Dock = DockStyle.Fill with the following property values:

ColumnCount = 2,
Dock = DockStyle.Fill,
CellBorderStyle = TableLayoutPanelCellBorderStyle.Single,
Visible = true,
AutoScroll = true,
AutoSize = false,

Each column contains a panel with Dock = DockStyle.Fill, which contains a LinkLabel with the following property values:

AutoSize = true,
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
UseCompatibleTextRendering = true,
Size = new Size(190, 19),
Font = new Font(this.Font.Name, 14.5f, FontStyle.Regular, GraphicsUnit.Pixel),
LinkBehavior = LinkBehavior.AlwaysUnderline,
Location = new Point(0, 0),

The text of the LinkLabel, which is dynamically set programmatically, can contain pretty long links which require horizontal scrolling by the TableLayoutPanel. Vertical scrolling, when a lot of rows are present, appears as required. Horizontal scrolling (via horizontal scroll bars), on the other hand, does not seem to appear even when there are a lot of characters in the LinkLabel. I have tried fiddling around with the AutoSize property by setting them all to false for every Control as, from my past experience, these can cause scroll bars to not appear.

Thanks in advance.

hecate
  • 620
  • 1
  • 8
  • 33
  • 1
    Your LinkLabel is child of a Panel. If something could scroll, is this Panel. This Panel is also set to fill the TLP Cell, so it cannot autosize but just autoscroll, eventually. The TLP doesn't notice it. – Jimi Jan 26 '20 at 16:46
  • What you could do is set the LinkLabel's Parent Panel to AutoSize, set all the TLP Column except the last to AutoSize, set the last as fixed width. In this case, the TLP will show the horizontal scroll bar when the fixed sized Column won't fit in. Or set all Columns to AutoSize, depending on the layout you're looking for. In this scenario, all columns will autosize to the longest string. It may be desired or not. – Jimi Jan 26 '20 at 16:56

1 Answers1

-1

Using AutoSize = true for TableLayoutPanel is not a good idea as TableLayoutPanel scrolling is full of bugs. It is often necessary to put the TableLayoutPanel in a dedicated parent Panel, which will do the scrolling stuff.

The solution provided here may help you : TableLayoutPanel displays vertical scroll

Bioukh
  • 1,888
  • 1
  • 16
  • 27