2012-10-10 69 views

回答

1

我會做到這一點的方法是將控件的高度存儲在一個全局變量,然後每次添加一個控件添加另一批高度的它。這會爲您提供每次移動位置所需的金額,以使控件顯示在下方。

然後在按鈕上單擊事件我將創建一個新的控件,並通過使用新的drawing.point並將X參數設置爲控件的當前X位置,然後將Y參數設置爲全局變量來設置位置。

int glHeightAccumalator = Control.Height; ' I would set this on the form load when you already have your first control in the Flow Layout Panel. 

''Button Click Event 

Control ctrl = new Control(); 
ctrl.Location = Drawing.Point(ctrl.Location.X, glHeightAccumalator); 
FlowLayoutPanel.Controls.Add(ctrl); 
glHeightAccumalator += ctrl.Height; 
相關問題