新建一个标准 EXE工程 菜单[工程]-[添加用户控件],选择用户控件,就进入用户控件设计界面 拖动一个文本框到界面上
里面写了些代码,新建的窗体里就加载了这个控件,想让程序运行时改变text里的内容,关闭程序再打开的时候text里内容为上次改过的内容,现在的问题是text内容改变后关闭程序在打开,还是text以前的内容,请教怎么能保存text里的内容。
Public Property Get TxtValue() As String
TxtValue = Text1.Text
End PropertyPublic Property Let TxtValue(ByVal pStr As String)
Text1.Text = pStr
PropertyChanged "TxtValue"
End PropertyPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Text = PropBag.ReadProperty("TxtValue", "2")
End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("TxtValue", Text1.Text, "")
End Sub
里面写了些代码,新建的窗体里就加载了这个控件,想让程序运行时改变text里的内容,关闭程序再打开的时候text里内容为上次改过的内容,现在的问题是text内容改变后关闭程序在打开,还是text以前的内容,请教怎么能保存text里的内容。
Public Property Get TxtValue() As String
TxtValue = Text1.Text
End PropertyPublic Property Let TxtValue(ByVal pStr As String)
Text1.Text = pStr
PropertyChanged "TxtValue"
End PropertyPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Text1.Text = PropBag.ReadProperty("TxtValue", "2")
End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("TxtValue", Text1.Text, "")
End Sub
额...
设计时更改的属性相当与默认值,这个会自动保存,这样才能编译到 exe 中。
运行时的属性是实时状态,不会保存。