Support for the Property Browser
When you select an object in Visual Studio, the public properties of that object appear in the Properties window. To select an object programmatically, add the object to a list of selectable and selected objects in a selection container. Use the STrackSelection service to notify Visual Studio of the selection.
There can be several lists of selected objects, only one of which is active. Visual Studio chooses the selection list to display in the Properties window depending on the window that has focus and other factors. For more information, see Walkthrough: Exposing Properties to the Properties Window.
Both managed package framework (MPF) and interop support are provided for creating selection containers, lists, and services from managed code.
MPF provides the SelectionContainer class to create a selection container. Selection containers have two collection properties, SelectableObjects and SelectedObjects. You can also create a selection container by implementing ISelectionContainer.
Get an ITrackSelection interface from the STrackSelection service, and then call OnSelectChange to notify Visual Studio of the selection. The public properties of the objects you add appear in the Properties window shortly after you call OnSelectChange.
To dispose of a property or object displayed in the Properties window, call OnSelectChange with a null selection container first. After disposing of the property or object, you can change to a selection container that has updated SelectableObjects and SelectedObjects lists.
The CategoryAttribute, DisplayNameAttribute, and DescriptionAttribute attributes determine the layout, labeling, and description of properties in the Properties window. These attributes determine the category, display name, and description of the option, respectively.
Equivalent attributes, SRCategory, LocDisplayName, and SRDescription, use string resources for localization and are defined in the managed project sample.
Consider the following code fragment.
The SomeText property appears in the Properties window as MyText in the category, My Properties. If the property is selected, the description, Simple Property, appears.