滚动条TableLayoutPanel c#
我有一个 TableLayoutPanel,里面有几个 TableLayoutPanel。数量会动态变化,并且几乎总是太多而无法容纳在表单中。我需要它有一个滚动条,以便我可以查看整个组件。
我尝试将主面板上的自动滚动属性设置为 true 并将其停靠和/或设置最大尺寸。相反,控制器所做的是尝试将所有面板放入表单中,从而更改其内部组件的大小并将它们全部挤压在一起,而不是创建滚动条来滚动我的面板。
你们知道我可能做错了什么吗?
谢谢。
Jose
PS:我使用的是 VS 2010
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有一天我遇到了同样的问题,发现问题是我为 TableLayoutPanel 设置了“MinimumSize”。这导致无论 Dock 和/或 Anchor 约束如何,控件都会保持最小高度,从而阻止自动滚动功能正常工作。由于该功能基于对控件的所有子控件的 Y 坐标与该控件的高度进行简单检查,因此尽管 TableLayoutPanel 的子控件由于其父控件而“消失”在视线之外,但滚动条并未出现剪辑区域。
换句话说,检查TableLayoutPanel 的MinimumSize 属性并确保它为空。
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.
也许这会有所帮助。
如果仍然不起作用,请尝试放置一个面板,然后将 tableLayoutPanel 放入该面板中。将面板的 autoScroll 属性设置为 true。
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.
我的项目中也发生了同样的事情。我的所有控件都被压缩在 TableLayoutPanel 内。就我而言,我将许多控件呈现为 ColumnStyle.Percent。将其切换为 ColumnStyle.Autosize 是我需要的修复。
我假设您也设置了这些属性,但以防万一我的 TableLayoutPanel 也使用以下设置:
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:
迟到的答案,但我最近一直在与复杂的布局作斗争,并且正在寻找一种解决方案,以使我的滚动在具有太多字段的屏幕上工作。老实说,更好的设计应该在 99% 的情况下避免这个问题,但有时你却束手无策。
问题
问题似乎在于,如果多个网格、组和面板嵌套得太深,它们将无法正确向父控件报告其内容已超出当前屏幕的大小。实际上,问题可能是控件都设置为停靠填充并且确实适合其父控件,因此顶级控件不知道其伟大伟大伟大的内容曾孙控件不适合。
解决方案
解决此问题的技巧似乎是手动强制最顶部的面板以某个最小尺寸滚动:
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:
TableLayoutPanel
滚动充满了错误。使其正常工作的解决方案位于此处。
TableLayoutPanel
scrolling is full of bugs.The solution to make it work correctly is here.