关于OCX自定义属性
小的想创建第一个OCX,只在OCX中放置一个label控件,调用者的Caption属性即label的Caption属性,只想用代码完成,程序如下:
'自定义属性
Public Property Get Caption() As String
Caption = Label11.Caption
End Property
Public Property Let Caption(ByVal NewCaption As String)
Label1.Caption = NewCaption
VB.UserControl.PropertyChanged "Caption "
End Property
Private Sub UserControl_InitProperties() '初始化属性
Caption = VB.UserControl.Extender.Name
End Sub
Private Sub UserControl_ReadProperties(ProBag As PropertyBag) '读属性
VBRUN.PropBag.ReadProperty "Caption "
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag) '写属性
VBRUN.PropBag.WriteProperty "Caption ", Caption
End Sub
结果屡试不成...请赐教T T
问题不是很难,请高手务必指点T T
要不小的必死矣T T
[解决办法]
Public Property Get Caption() As String
Caption = Label1.Caption
End Property
Public Property Let Caption(ByVal NewCaption As String)
Label1.Caption = NewCaption
PropertyChanged "Caption "
End Property
Private Sub Label1_Click()
End Sub
Private Sub UserControl_InitProperties() '初始化属性
Caption = Extender.Name
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag) '读属性
Label1.Caption = PropBag.ReadProperty( "Caption ", "Label1 ")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag) '写属性
PropBag.WriteProperty "Caption ", Label1.Caption, "Label1 "
End Sub