Freigeben über


How to: Update Property Values in the Properties Window

There are two ways to keep the Properties window in sync with property value changes. The first is to call the IVsUIShell interface, which provides access to basic windowing functionality, including access to and creation of tool and document windows provided by the environment. The following steps describe this synchronization process.

Updating Property Values Using IVsUIShell

To update property values using the IVsUIShell interface

  1. Call IVsUIShell (through SVsUIShell service) any time that VSPackages, projects, or editors need to create or enumerate tool or document windows.

  2. Implement RefreshPropertyBrowser to keep the Properties window in sync with property changes for a project (or any other selected object being browsed by the Properties window) without implementing IConnectionPointContainer and firing OnChanged events.

  3. Implement the IVsHierarchy methods AdviseHierarchyEvents and UnadviseHierarchyEvents to establish and disable, respectively, client notification of hierarchy events without requiring the hierarchy to implement IConnectionPointContainer.

Updating Property Values Using IConnection

The second way to keep the Properties window in sync with property value changes is to implement IConnection on the connectable object to indicate the existence of the outgoing interfaces. If you wish to localize the property name, derive your object from ICustomTypeDescriptor. The ICustomTypeDescriptor implementation can modify the property descriptors it returns and change the name of a property. To localize the description, create an attribute which derives from DescriptionAttribute and override the Description property.

Considerations in implementing the IConnection interface

  1. IConnection provides access to an enumerator sub-object with the IEnumConnectionPoints interface. It also provides access to all the connection point sub-objects, each of which implements the IConnectionPoint interface.

  2. Any browse object is responsible for implementing an IPropertyNotifySink event. The Properties window will advise for the event set through IConnection.

  3. A connection point controls how many connections (one or more) it allows in its implementation of Advise. A connection point that allows only one interface can return E_NOTIMPL from the EnumConnections method.

  4. A client can call the IConnection interface to obtain access to an enumerator sub-object with the IEnumConnectionPoints interface. The IEnumConnectionPoints interface can then be called to enumerate connection points for each outgoing interface ID (IID).

  5. IConnection can also be called to obtain access to connection point sub-objects with the IConnectionPoint interface for each outgoing IID. Through the IConnectionPoint interface, a client starts or terminates an advisory loop with the connectable object and the client's own sync. The client can also call the IConnectionPoint interface to obtain an enumerator object with the IEnumConnections interface to enumerate the connections that it knows about.

See Also

Tasks

How to: Announce Selection Tracking to the Environment

Other Resources

Properties Window and Property Pages