2013-07-02 92 views
1

嘗試設置幾個groupboxes的位置時,我得到的問題...調整大小的形式問題

這是默認大小的應用程序的圖片,

的groupboxes都在中間的形式,這就是我想要的。 enter image description here

這是另一張照片中,當應用程序的大小時,

的groupboxes移動到左側,他們還不是在中間

錨的groupboxes的財產被「權「(我已經嘗試了所有組合) enter image description here

這是應用程序的圖片充滿時最大化,

groupboxes是移動到右側。 enter image description here

我想在調整大小時保留tabpage中間的組框。

這裏有一個視頻:http://www.youtube.com/watch?v=itZ85hRh9dQ&feature=youtu.be

+1

是的,WinForms對於這種事情並不是很好。當Form.OnResize事件觸發時,您可能需要重新定位並調整它們的大小。 WPF是前進的方向,這種事情是支持 – musefan

+0

也許你可以使用面板..使他們在面板和照顧面板上的形式調整大小的事件.. – matzone

+1

@musefan感謝您的「可能重複」,在我看到解決方案的鏈接是不嘗試任何錨點組合,將錨點設置爲「無」,解決了! – ElektroStudios

回答

2

或許,如果你沒有找到任何其他解決方案,您可以取代他們在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) 

希望這有助於(和工程...我還沒有嘗試過):)