[英]Center controls in a panel c#
I have a panel where controls are added dynamically.我有一个面板,其中动态添加控件。 I would like to be able to center all of them on it is panel because for now, they are all glued on the left
我希望能够将所有这些都集中在面板上,因为现在,它们都粘在左侧
I read that we had to divide the panel and all of them, but I must admit that I didn't understand anything.我读到我们必须将小组和所有人分开,但我必须承认我什么都不明白。 Could someone please help me so I can all center?
有人可以帮助我,这样我就可以全部居中了吗?
Thank you.谢谢你。
In the VS Designer try to set the Anchor
and the Dock
Property to None
.在 VS Designer 中尝试将
Anchor
和Dock
属性设置为None
。 The Control will then be placed in the middle.然后将控件放置在中间。
EDIT: Alternativly you can can iterate over those controls and set their Control.Location.X += (Parent.Width - Control.Width / 2);
编辑:或者,您可以迭代这些控件并设置它们的
Control.Location.X += (Parent.Width - Control.Width / 2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.