VB.net 如何按中心放大控件

来源:百度知道 编辑:UC知道 时间:2024/06/10 21:39:11
在VB.net中,当我增加控件的高度和宽度时,系统默认是往右下方增长的,如何让它按中心增长大小?相关代码如下:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.PictureBox1.Width += 1
Me.PictureBox1.Height += 1
'Me.PictureBox1.Left -= 1 //原本以为写这两句代码就可以使其按中心放大,结果却不行
'Me.PictureBox1.Top -= 1
If Me.PictureBox1.Width >= 80 Or Me.PictureBox1.Height >= 80 Then Timer1.Enabled = False
End Sub

求救中,哪位好心人帮忙解答一下!

Dim old_myform_width As Single
Dim old_myform_height As Single
Dim new_myform_width As Single
Dim new_myform_height As Single
Dim x_scale As Single
Dim y_scale As Single

Private Sub myform_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
new_myform_width = MyBase.Size.Width
new_myform_height = MyBase.Size.Height

x_scale = new_myform_width / old_myform_width
y_scale = new_myform_height / old_myform_height

old_myform_width = new_myform_width
old_myform_height = new_myform_height

Dim mycontrol As New Control
For Each mycontro