Resize 事件

调整用户窗体时发生。

语法

专用子UserForm_Resize ( )

备注

在调整父 UserForm 的大小时,使用 Resize 事件过程移动控件或调整控件大小。 还可以使用此事件过程重新计算变量属性

示例

以下示例使用 ActivateClick 事件来说明 UserFormResize 事件的触发。 当用户单击窗体的工作区时,窗体的工作区会增大或收缩,并在标题栏中指定新高度。 请注意, Tag 属性用于存储 UserForm 的初始高度。

' Activate event for UserForm1
Private Sub UserForm_Activate()
    UserForm1.Caption = "Click me to make me taller!"
    Tag = Height    ' Save the initial height.
End Sub

' Click event for UserForm1
Private Sub UserForm_Click()
    Dim NewHeight As Single
    NewHeight = Height
    ' If the form is small, make it tall.
    If NewHeight = Val(Tag) Then
        Height = Val(Tag) * 2
    Else
    ' If the form is tall, make it small.
        Height = Val(Tag)
    End If
End Sub

' Resize event for UserForm1
Private Sub UserForm_Resize()
    UserForm1.Caption = "New Height: " & Height & "  " & "Click to resize me!"
End Sub

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。