Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
554 views
in Technique[技术] by (71.8m points)

winforms - Can Margin be enforced even with Dock property set?

I have a WinForms Form with a few controls on it. All of them are GrouBox controls and I want them stacked, with a vertical margin set between them. I have set the Dock property to Top and it stacks them alright, but ignores the margin (controls are as close to each other as they can be).

Can these margins still somehow be enforced? Basically, it would calculate the regular docked position (as if the margin was 0) then apply the margin. Is something like this possible?

The other way I've tried this is with FlowLayoutPanel with TopDown option. However, then I need to manually set the size and Left/Right anchors.

Is there any easy way to acomplish this scenario or should I stick with what I already have?

question from:https://stackoverflow.com/questions/7057868/can-margin-be-enforced-even-with-dock-property-set

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The set docking property will ignore your padding properties between GroupBox controls, so yes, your best bet is the Flow or Table panels to do this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...