放到form_resize()过程中
msflexgrid.move 0,0,me.scalewidth,me.scaleheight
或是
with msflexgrid
.left=me.left
.top=0
.width=me.scalewidth
.height=me.scaleheight
end with
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
End Sub
Public Sub ResizeForm(FormName As Form) '当窗体大小发生变化时,各控件尺寸及位置作相应变化
Dim Pos '控件原先尺寸、位置
Dim I As Long '计数器
Dim Obj As Control '遍历窗体内控件
Dim ScaleX As Double, ScaleY As Double '缩放比例
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
On Error Resume Next
For Each Obj In FormName
Pos = Split(Obj.Tag, " ", , vbTextCompare)
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next Obj
End Sub
以下放到你msflexgrid所在的窗体内。
Private Sub Form_Load()
Call ResizeInit(Me)
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub