简体   繁体   中英

How to use Dock-> Fill with an offset?

I have a Windows Media Player-Compononent. 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.

Add a panel set its dock to Bottom , then add a Media(whatever) component set its dock to Fill . You're done.

You don't need any additional Panels or SplitContainers. 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). Then set all anchors of control (How to: Anchor Controls on Windows Forms) . 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. It looked like it worked but text would appear off panel1 down under panel2 .

I fixed this with the padding property . I added 20 padding to the bottom of panel1 and all was fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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