This documentation is archived and is not being maintained.

SelectionContainer Class

Provides a unified interface for accessing a set of selected objects.

Object
  Microsoft.VisualStudio.Shell.SelectionContainer

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

'Declaration
Public Class SelectionContainer _
	Implements ISelectionContainer

The SelectionContainer type exposes the following members.

  NameDescription
Public methodSelectionContainerInitializes a new SelectionContainer object. The overload provides the ability to restrict user control over the SelectableObjects and SelectedObjects collections.
Public methodSelectionContainer(Boolean, Boolean)Creates a new SelectionContainer object with the ability to restrict user control over the SelectableObjects and SelectedObjects collections.
Top

  NameDescription
Public propertySelectableObjectsGets the collection of selectable objects.
Public propertySelectedObjectsGets or sets the collection of selected objects.
Top

  NameDescription
Protected methodActivateObjectsOverriding this method enables an object to respond when selected.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventSelectedObjectsChangedRaised when an external object calls the ISelectionContainer.SelectObjects method with the SELECTED flag set.
Top

  NameDescription
Public fieldStatic memberALLRefers to all SelectableObjects.
Public fieldStatic memberSELECTEDRefers to all SelectedObjects.
Top

  NameDescription
Explicit interface implemetationPrivate methodISelectionContainer.CountObjectsDetermines the number of objects either those SELECTED or ALL items.
Explicit interface implemetationPrivate methodISelectionContainer.GetObjectsSets cObjects with the number of items SELECTED or ALL items and populates array apUnkObjects with pointers to those objects.
Explicit interface implemetationPrivate methodISelectionContainer.SelectObjectsSets the collection of selectable objects.
Top

The SelectionContainer class provides a unified interface for accessing a set of selected objects. It implements all of the methods defined by the ISelectionContainer interface, and adds a new method, ActivateObjects, that enables an object to respond when selected.

Typically, the contents of the selection container are modified when an external object calls [SelectObjects], which triggers a SelectedObjectsChanged event (and can also call the ActivateObjects method, if it is implemented.) The contents of the selection container can also be examined or changed by accessing the SelectedObjects or SelectableObjects properties.

When changes occur that affect the Properties window, the VSPackage must alert the environment by calling the OnSelectChange method with the selection container that reflects the current selection context. The shell then makes calls to SelectionContainer methods to retrieve one or more IDispatch objects, which provide access to the data needed to update the Properties window.

This class also simplifies some interoperability issues with the ISelectionContainer interfaces. Different versions of Visual Studio implement different versions of ISelectionContainer, and SelectionContainer provides seamless interoperability with the different implementations.

Notes to Implementers

A selection container is the mechanism used by windows to push information to the Properties window. A VSPackage should include a SelectionContainer object for each object (typically a window) that contains selectable objects with related properties to be displayed in the Properties window.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: