简体   繁体   English

如何使用Dock->用偏移量填充?

[英]How to use Dock-> Fill with an offset?

I have a Windows Media Player-Compononent. 我有Windows Media Player组件。 I want it to fill the whole form except a line at the bottom for some buttons and Text. 我希望它填充整个表单,除了一些按钮和文本底部的一行。 So Dock-> Fill minus the part at the bottom but when resized, the part at the bottom should resize to left and right but stay at the bottom and the Windows Media Player-Compononent should resize with the form but keep the distance at the bottom. 因此,Dock-> Fill减去底部的零件,但是在调整大小时,底部的零件应左右调整大小,但应留在底部,而Windows Media Player组件应随表格调整大小,但将距离保持在底部。

Add a panel set its dock to Bottom , then add a Media(whatever) component set its dock to Fill . 添加一个面板,将其停靠设置为Bottom ,然后添加一个Media(what)组件,将其停靠设置为Fill You're done. 你完成了。

You don't need any additional Panels or SplitContainers. 您不需要任何其他面板或SplitContainer。 Problem can be solved with proper docking and anchoring. 可以通过适当的对接和锚固来解决问题。 Place your control on form and resize it so that line at the bottom will stay (you can easily do it by setting dock to top). 将您的控件放在窗体上并调整其大小,以使底部的行保持不变(您可以通过将dock设置为顶部来轻松完成此操作)。 Then set all anchors of control (How to: Anchor Controls on Windows Forms) . 然后设置控件的所有锚点 (方法:在Windows窗体上 锚定 控件) That will bound all edges of control to edges of form, and you will have constant height line at the bottom of form. 这会将控件的所有边缘都绑定到窗体的边缘,并且在窗体的底部将具有恒定的高度线。

Result (green is your control): 结果(绿色为您的控件):

在此处输入图片说明在此处输入图片说明

For anyone else having this issue: 对于其他任何有此问题的人:

I had 2 panels stacked panel1 was fill, panel2 was bottom docked. 我有2个面板堆叠, panel1被填充, panel2被底部固定。 It looked like it worked but text would appear off panel1 down under panel2 . 看起来好像panel1 ,但文本将在panel1下方的panel2panel2

I fixed this with the padding property . 我用padding属性修复了这个问题。 I added 20 padding to the bottom of panel1 and all was fixed. 我在panel1的底部添加了20 padding ,所有这些都已修复。

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

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