C# 在 FlowLayoutPanel 中调整用户控件之间的间距
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11330734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adjusting spacing between usercontrols in a FlowLayoutPanel
提问by wonea
I'm building a WinForms application Window (form), inside that I'm using a FlowLayoutPanel, with usercontrols added to this. Now I've been looking through the properties of both the FlowLayoutPanel and UserControl but can't seem to find anything to do with the spacing between usercontrols. I want the usercontrols to be closer to each other, if only by a couple of pixels. The usercontrols themselves have no space either side of the numericUpDown. Any suggestions would be helpful.
我正在构建一个 WinForms 应用程序窗口(窗体),其中我使用的是 FlowLayoutPanel,并添加了用户控件。现在我一直在查看 FlowLayoutPanel 和 UserControl 的属性,但似乎找不到与用户控件之间的间距有关的任何内容。我希望用户控件彼此更接近,即使只有几个像素。用户控件本身在 numericUpDown 的两侧都没有空格。任何的意见都将会有帮助。
My FlowLayoutPanel:
我的 FlowLayoutPanel:


采纳答案by IAbstract
Paneland other similar controls have both Marginand Paddingproperties. Padding determines spacing internal to the control ...such as a panel. If Padding is set to 3 (All) in a Panel control, then controls will snap to 3 pixels of padding against internal edges of the control.
Panel和其他类似的控件同时具有Margin和Padding属性。填充确定控件内部的间距......例如面板。如果在 Panel 控件中将 Padding 设置为 3(全部),则控件将对齐控件内部边缘的 3 个填充像素。
Margin works the same way, but between other controls. If Margin is set to 3 (All), controls will automatically snap to the margin spacing.
Margin 的工作方式相同,但在其他控件之间。如果边距设置为 3(全部),控件将自动对齐边距间距。
I haven't used the FlowLayoutPanel but once and, IIRC, you can set padding for the cells. Check your margin on your user control, and check the padding for the layout cells. Set one to 0 and the other to 3.
我没有使用过 FlowLayoutPanel 但有一次,IIRC,您可以为单元格设置填充。检查用户控件上的边距,并检查布局单元格的填充。将一个设置为 0,另一个设置为 3。

