vb6没有提供这种机制来继承控件的属性。只有自己来实现,如Event Change()public property get BackColor as ole_color BackColor = Text1.BackColor end propertypublic property let BackColor (byval vData as ole_color) Text1.BackColor = vData PropertyChange "BackColor" end propertyprivate sub Text1_Change() RaiseEvent Change() end sub
使用枚举类型即可以在属性窗口里面选择。如:Public Property Get Alignment() As AlignmentConstants Alignment = Text1.Alignment End PropertyPublic Property Let Alignment(ByVal vData As AlignmentConstants) Text1.Alignment = vData PropertyChanged "Alignment" End Property
BackColor = Text1.BackColor
end propertypublic property let BackColor (byval vData as ole_color)
Text1.BackColor = vData
PropertyChange "BackColor"
end propertyprivate sub Text1_Change()
RaiseEvent Change()
end sub
RaiseEvent也可以用了
现在还有一个问题再请教一下,比如定义控件的alignment属性,怎么让实例在应用时会动枚举出属性值供选择呢?
谢谢
Alignment = Text1.Alignment
End PropertyPublic Property Let Alignment(ByVal vData As AlignmentConstants)
Text1.Alignment = vData
PropertyChanged "Alignment"
End Property