PRB: Custom ActiveX Property Sheet Entries Are Not Saved

Last reviewed: March 24, 1997
Article ID: Q161139
The information in this article applies to:
  • Microsoft Visual Basic Control Creation and Enterprise Editions, for Windows, version 5.0

SYMPTOMS

ActiveX control property changes entered via a property page are not saved. However, if you enter the properties via the standard property pane that comes with Visual Basic, the changes are saved.

CAUSE

The UserControl needs to explicitly inform the host development environment of any property changes that are made via property pages or are side effects of other property changes.

RESOLUTION

To tell the host development environment of property changes, the UserControl must invoke the PropertyChanged method of the Extender object.

STATUS

This behavior is by design.

MORE INFORMATION

When entering properties via the standard property pane, the host application is setting the properties for your control and, therefore, knows they have been changed.

The host application knows nothing about changes you make via property pages or that there are side effects of other property changes. The user control needs to explicitly tell the host application that properties have been changed, so it can see the changes and save them.

The following example illustrates setting properties:

   ------ in the property page ------

      Private Sub LabelCaption_Changed()
        Changed = True     ' Enable Apply button
      End Sub

      Private Sub ApplyChanges()
      Dim X As Variant
        For Each X In SelectedControls
          X.Caption = LabelCaption.Text
        Next X
      End Sub

   ------ in the user control ------

      Public Property Let Caption(ByVal NewVal As String)
        lblMain.Caption = NewVal
        PropertyChanged "Caption"
      End Sub

This code assumes that you have all other supporting code working, such as the InitProperties, ReadProperties, and WriteProperties events.

REFERENCES

Microsoft Visual Basic Online Help, PropertyChanged Method

Microsoft Visual Basic Component Tools Guide, Chapter 9, Building ActiveX Controls, Adding Properties to Controls, Implement Control Properties Using Property Procedures


Keywords : kbprg vb5all vb5howto VBKBAX VBKBProgramming kbprb
Technology : kbole
Version : 5.0
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.