Table layout panel scroll bar

六月ゝ 毕业季﹏ 提交于 2019-12-30 03:42:07

问题


given a table layout panel with 2 columns and many rows, how can i attatch a scroll bar to it as sometimes it grows much greater than the size of the form .

Thank you


回答1:


The TableLayoutPanel is an example of a ScrollableControl. You can therefore set it's AutoScroll property to True and the control will automatically create scroll bars when it's preferred size exceeds its current size. This will provide you with the desired effect with minimal hassle.

Procedure

  1. Set the MaximumSize property to a preferred maximum size or you can dock the TableLayoutPanel in your form.
  2. Set the AutoScroll property of the TableLayoutPanel to true.



FYI:
The Panel, ToolStrip, FlowLayoutPanel, SplitterPanel, TableLayoutPanel, TabPage and ToolStripContentPanel all inherit the ScrollableControl class so this answer applies to them as well.




回答2:


For shortcut :

tableLayoutPanel1.MaximumSize = new Size(tableLayoutPanel1.Width, tableLayoutPanel1.Height);
tableLayoutPanel1.AutoScroll = true;



回答3:


.Net Framework WinForms TableLayoutPanel has a lot of bugs with AutoScroll. It's better to avoid use this property. There is better solution. I hope they will be fixed in .Net Core WinForms version.



来源:https://stackoverflow.com/questions/4794153/table-layout-panel-scroll-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!