When the end user of an ActiveX document views a document, there may be several text boxes that she or he will fill out as part of your application. If it's possible that the user will return repeatedly to the document, you may wish to save some time by saving the data to the PropertyBag.
In the following example, the PropertyChanged statement is inserted into the Change event of the TextBox (txtFirstDoc) control. This causes Internet Explorer to prompt the user to save changes. If the user responds positively, the code writes the property value to the PropertyBag.
For More Information To learn more about the PropertyBag, see "Saving the Properties of Your Control" in "Building ActiveX Controls."
Note This topic is part of a series that walks you through creating a sample ActiveX control. It begins with the topic Creating an ActiveX Document.
To write and read a property to the PropertyBag
Private Sub txtFirstDoc_Change()
PropertyChanged
End Sub
Private Sub UserDocument_WriteProperties _
(PropBag As VB.PropertyBag)
PropBag.WriteProperty "StrDocProp", _
txtFirstDoc.Text, "Hello"
Debug.Print "WriteProperties"
End Sub
Private Sub UserDocument_ReadProperties _
(PropBag As VB.PropertyBag)
txtFirstDoc.Text = _
PropBag.ReadProperty("StrDocProp", _
"Hello")
Debug.Print "ReadProperties"
End Sub
Now that the property can be written to and read from the PropertyBag, run the project to test it.
Using the PropBag in conjunction with the WriteProperties and ReadProperties events, you can easily persist data for your object.
This topic is part of a series that walks you through creating a sample ActiveX document.
To | See |
Go to the next step | Adding a Menu to the ActXDoc Project |
Start from the beginning | Creating an ActiveX Document |