VB 制作控件 怎么使用时拖动控件大小时控件里面的东西也随着变化 10
两种方式可以实现:
使用Rsize控件,只要加载控件到界面即可。控件需要下载。
在fromRsize, 属性中,按照窗体大小进行界面加载。需要按照程序需要进行书写,比较麻烦,但是可以控制界面的美观。我的程序中都用这种:
例子:
Dim winWidth As Long
Dim winHeight As Long
On Error Resume Next ‘一定写上,不然窗体最小化会报错滴。
winWidth = Me.ScaleWidth
winHeight = Me.ScaleHeight
Lab_BT.Top = 0
Lab_BT.Left = (winWidth - Lab_BT.Width) / 2
Line1.X1 = 1500
Line1.X2 = winWidth - 1500
Line1.Y1 = Lab_BT.Height + 200
Line1.Y2 = Line1.Y1
Fra_hz.Top = Line1.Y1 + 100
Fra_hz.Left = 100
Fra_hz.Height = winHeight - Fra_hz.Top - 100
DT_FYSJ.Top = 270
DT_FYSJ.Left = 100
DT_FYSJ.Width = Fra_hz.Width - 200
LV_hz.Top = DT_FYSJ.Top + DT_FYSJ.Height + 100
LV_hz.Left = 100
LV_hz.Width = Fra_hz.Width - 200
LV_hz.Height = Fra_hz.Height - LV_hz.Top - Cmd_sx.Height - 200
Cmd_sx.Left = 100
Cmd_sx.Width = LV_hz.Width
Cmd_sx.Top = LV_hz.Top + LV_hz.Height + 100
Fra_mx.Top = Fra_hz.Top
Fra_mx.Left = Fra_hz.Width + Fra_hz.Left + 100
Fra_mx.Width = winWidth - Fra_mx.Left - 100
Fra_mx.Height = Fra_hz.Height - Fra_cz.Height - 100
LV_mx.Top = 270
LV_mx.Left = 100
LV_mx.Width = Fra_mx.Width - 200
LV_mx.Height = Fra_mx.Height - LV_mx.Top - 100
Fra_cz.Top = winHeight - Fra_cz.Height - 100
Fra_cz.Left = Fra_hz.Left + Fra_hz.Width + 100
Fra_cz.Width = winWidth - Fra_hz.Width - 300
Ck_qx.Left = 300
Cmd_tc.Left = Fra_cz.Width - Cmd_tc.Width - 300
Cmd_dy.Left = Cmd_tc.Left - Cmd_dy.Width - 300
On Error GoTo 0 ’结束On Error