为什么无法为自己设计的控件的Picture属性赋值
编号:QA003224
建立日期: 2000年7月30日 最后修改日期:2000年7月30日
所属类别:
ligl:
操作系统: win98
编程工具: vb6.0
问题: 我将Image放置在UserContro上,并使用下列代码让Image显示输入的图片,
Public Property Get Picture() As Picture
Set Picture = Image1.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set Image1.Picture = New_Picture
PropertyChanged "Picture"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
End Sub
编译后发现,在控件属性窗口Picture属性中可设定各种图片,但在代码窗口中却不能使用UserControl.Picture=LoadPicture([stringexpression])
语句,也不能使用UserControl.Picture=object.Picture语句。请问是原因,如何解决。谢谢!
水平: 中级
回答:
Picture属性有点特殊,一般的对象都只有Property Set,而没有 Property Let过程,但Picture属性应该包括这两个过程。你的代码中没有Property Let过程,所以只能使用Set UserControl.Picture=LoadPicture([stringexpression])的格式赋值。如果想使用UserControl.Picture=LoadPicture([stringexpression])格式,必须增加一个Property Let过程
此问题由李海回答。
| |
|
|
| |
|
|