我做了一个自定义控件,在属性对话框里设置好了一个属性,但是一运行属性又恢复成默认值了,我该怎么办?

解决方案 »

  1.   

    响应ReadProperties和WriteProperty事件,如:
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
        Text1.text = PropBag.ReadProperty("text", "") '读取属性值
    End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)
        PropBag.WriteProperty "text", Text1.text, ""   '保存属性值
    End Sub
      

  2.   


    Text1.text = PropBag.ReadProperty("text", "") '读取属性值
    改成
    Text1.text = PropBag.ReadProperty("text", Ambient.DisplayName) '读取属性值然后在下面要把要引用Text1.text属性的自定义控件的值,变成Text1.text的值