简体   繁体   English

如何以 C# windows 形式查看面板控件内部

[英]How to view inside of a panel control in C# windows form

I am trying to place a panel that I want to have multiple textboxes inside of.我正在尝试放置一个我想要在其中包含多个文本框的面板。 I want this panel to fit inside the form and the panel to have a scrollbar.我希望这个面板适合窗体和面板有一个滚动条。 I have autoscroll on and its working as intended, but I want to be able to add controls below the size of the panel.我启用了自动滚动并按预期工作,但我希望能够在面板大小以下添加控件。 Is there a way I can "full screen" the panel and place items in it or even make the scrollbar a set length instead of just the amount needed to fit the contents.有没有一种方法可以让我“全屏显示”面板并在其中放置项目,甚至可以使滚动条设定长度,而不仅仅是适合内容所需的长度。 I want to be able to place things underneath what I have there.我希望能够将东西放在我所拥有的东西下面。

面板底部示例

Dragging items onto the panel doesn't allow enough room to make things tidy将项目拖到面板上没有足够的空间使事情变得整洁

As an option, you can set the AutoScrollMinSize , in your case, the height of it to a larger value like 1000 temporarily, which sets the virtual (Scrillable) height of the control to 1000. The property determines the minimum size of scrollable area.作为一个选项,您可以设置AutoScrollMinSize ,在您的情况下,它的高度暂时设置为较大的值,如 1000,这会将控件的虚拟(可滚动)高度设置为 1000。该属性确定可滚动区域的最小大小。

As another option, you can AutoScrollMargin , in your case, the height of it, to something like 500 temporarily, which provides an extra 500 pixels space at bottom of the panel.作为另一种选择,您可以将AutoScrollMargin ,在您的情况下,它的高度暂时设置为 500 之类的值,这会在面板底部提供额外的 500 像素空间。 The property determines the minimum margin that should be between the edge of the child control and the edge of the scrollable control.该属性确定子控件边缘和可滚动控件边缘之间的最小边距。

Then when you are done with the design, just right click on the property and Reset the value of it, to let the control calculate the scroll size.然后当你完成设计时,只需右键单击属性并重置它的值,让控件计算滚动大小。

And I assume you are aware of some obvious workarounds like:我假设您知道一些明显的解决方法,例如:

  • Design the form (including the panel) in a larger size, setting proper dock and and anchor properties for controls, later set the size of form to desired size at run-time, or at design time (after you are done with the initial designs).设计更大尺寸的窗体(包括面板),为控件设置适当的停靠和锚点属性,稍后在运行时或设计时(完成初始设计后)将窗体大小设置为所需大小).
  • Or another workaround, could be just dropping the controls in the panel, and then selecting them and moving them using arrow keys.或者另一种解决方法,可能只是将控件放在面板中,然后选择它们并使用箭头键移动它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM