或許,如果你沒有找到任何其他解決方案,您可以取代他們在form_resize事件。 我想你使用Groupboxes ...這有助於很多! 你應該做這樣的事情爲單GroupBoxes(如計劃在您的示例):
groupBox1.Location.X = Me.Width/2 - groupBox1.Width/2
而這樣的事情更多GroupBoxes水平(如文件和自定義)
Dim dist As Int32 = groupBoxCustomization.Location.X - groupBoxFiles.Width + groupBoxFiles.Location.X
'Get the distance between groupBoxCustomization and groupBoxFiles
Dim groupWidth As Int32 = groupBoxCustomization.Width + groupBoxCustomization.Location.X - groupBoxFiles.Location.X
'Get the total width of the GroupBoxes including the distance between them
'Now you use the same system than before, just imagine to have only one large GroupBox
groupBoxFiles.Location.X = Me.Width/2 - groupWidth/2
'Now you have fixed the first GroupBox, you know the distance between the GroupBoxes, and the widths are constant, so it's easy!
groupBoxCustomization.Location.X = groupBoxFiles.Location.X + groupBoxFiles.Width + dist
您可能需要以計算轉換爲整數,如果是的話,使用此代碼
intValue = CInt(double)
希望這有助於(和工程...我還沒有嘗試過):)
是的,WinForms對於這種事情並不是很好。當Form.OnResize事件觸發時,您可能需要重新定位並調整它們的大小。 WPF是前進的方向,這種事情是支持 – musefan
也許你可以使用面板..使他們在面板和照顧面板上的形式調整大小的事件.. – matzone
@musefan感謝您的「可能重複」,在我看到解決方案的鏈接是不嘗試任何錨點組合,將錨點設置爲「無」,解決了! – ElektroStudios