Dim panelA As New Panel
Dim panelB As New Panel
panelA.BackColor = Color.White
panelB.BackColor = Color.Black
panelA.Width = 100
panelA.Height = 100
panelB.Width = 50
panelB.Height = 50
Me.Controls.Add(panelA)
panelA.Controls.Add(panelB)
panelB.Top = CInt((panelA.Width - panelB.Width) / 2)
panelB.Left = CInt((panelA.Width - panelB.Width) / 2)
This code will create 2 panels, one centred inside the other.
Run it from a form button or load event,
Me.Controls
represent the form.
Works fine for me.