2013-02-14 63 views
0

我在VB.Net中有两个面板。父面板(panel1)停靠在窗体调整大小时调整大小的表单上。保持面板居中vb.net

子面板(panel2)应该位于panel1的中心,但是当它的父级或表单调整大小时,该中心不会由panel2保存。

总之,我怎样才能将panel2始终保持在panel1的中心?

我使用VB.net。

回答

1

尝试这样:

Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize 
    Panel2.Top = (Panel1.Height - Panel2.Height)/2 
    Panel2.Left = (Panel1.Width - Panel2.Width)/2 
End Sub 
1

在属性选项卡:

 1. Set Dock property from Panel2 to Fill 
     2. Set Panel1 padding property to something like: 50;50;50;50 
     and increase/decrease the values in order to get the result you want.