面板位置 [英] Panel Location
本文介绍了面板位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我尝试放置面板,但它没有到达所需位置。
其实我的要求是将Panel_B放在Panel_A的正中心位置。
Dear All,
I try to place panel but it is not coming at required position.
Actually My requirement is to place the Panel_B inside the Panel_A exactly at centre position.
Dim xx, yy As Integer
xx = (PANEL_A.Width - Panel_B.Width)
yy = (PANEL_A.Height - Panel_B.Height)
PanelB.Location = New System.Drawing.Point(CInt(xx / 2), CInt(yy / 2))
请指导。
Please guide.
推荐答案
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)
此代码将创建2个面板,一个位于另一个内部。
运行它表单按钮或加载事件, Me.Controls
表示表单。
适用于我。
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.
这篇关于面板位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文