Private Sub UserControl_AmbientChanged(PropertyName As String)
If PropertyName = "DisplayName" Then
'' 当index属性改变时会引发,此时把index值在label1中显示
Label1.Caption = UserControl.Extender.Index
End If
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'' 仅在运行时显示label控件
Label1.Visible = Not UserControl.Ambient.UserMode
'' 确保每次在设计时显示窗口时都能显示index的值
Label1.Caption = UserControl.Extender.Index
End Sub