用户控件窗口下用了两个图片控件Picture1和Picture2
例图1:
自定义成员属性A1和A2,A1=Picture1.Picture      A2=Picture2.Picture   
代码:
'注意!不要删除或修改下列被注释的行!
'MappingInfo=Picture1,Picture1,-1,Picture
Public Property Get a1() As Picture
    Set a1 = Picture1.Picture
End PropertyPublic Property Set a1(ByVal New_a1 As Picture)
    Set Picture1.Picture = New_a1
    PropertyChanged "a1"
End Property'注意!不要删除或修改下列被注释的行!
'MappingInfo=Picture2,Picture2,-1,Picture
Public Property Get a2() As Picture
    Set a2 = Picture2.Picture
End PropertyPublic Property Set a2(ByVal New_a2 As Picture)
    Set Picture2.Picture = New_a2
    PropertyChanged "a2"
End Property'从存贮器中加载属性值
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)    Set Picture = PropBag.ReadProperty("a1", Nothing)
    Set Picture = PropBag.ReadProperty("a2", Nothing)
End Sub'将属性值写到存储器
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)    Call PropBag.WriteProperty("a1", Picture, Nothing)
    Call PropBag.WriteProperty("a2", Picture, Nothing)
End Sub生成ocX后在EXE工程里面调用 将A1绑定一张图 再将A2绑定一张图片, 在没有点击运行的时候显示正常,点击运行程序后图片就没有了自动清空了,这个什么原因啊?
图2:
控件

解决方案 »

  1.   

    你这样情况下,向导生成的大妈有问题以下两个过程这样修改
    '从存贮器中加载属性值
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)    Set Picture1.Picture = PropBag.ReadProperty("a1", Nothing)
        Set Picture2.Picture = PropBag.ReadProperty("a2", Nothing)
    End Sub'将属性值写到存储器
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)    Call PropBag.WriteProperty("a1", Picture1.Picture, Nothing)
        Call PropBag.WriteProperty("a2", Picture2.Picture, Nothing)
    End Sub