Compartilhar via


SelectionContainer Class

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

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Shell.SelectionContainer

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

Syntax

'Declaração
Public Class SelectionContainer _
    Implements ISelectionContainer
public class SelectionContainer : ISelectionContainer

The SelectionContainer type exposes the following members.

Constructors

  Name Description
Public method SelectionContainer() Initializes a new SelectionContainer object. The overload provides the ability to restrict user control over the SelectableObjects and SelectedObjects collections.
Public method SelectionContainer(Boolean, Boolean) Creates a new SelectionContainer object with the ability to restrict user control over the SelectableObjects and SelectedObjects collections.

Top

Properties

  Name Description
Public property SelectableObjects Gets the collection of selectable objects.
Public property SelectedObjects Gets or sets the collection of selected objects.

Top

Methods

  Name Description
Protected method ActivateObjects Overriding this method enables an object to respond when selected.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event SelectedObjectsChanged Raised when an external object calls the ISelectionContainer.SelectObjects method with the SELECTED flag set.

Top

Fields

  Name Description
Public fieldStatic member ALL Refers to all SelectableObjects.
Public fieldStatic member SELECTED Refers to all SelectedObjects.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method ISelectionContainer.CountObjects Determines the number of objects either those SELECTED or ALL items.
Explicit interface implemetationPrivate method ISelectionContainer.GetObjects Sets cObjects with the number of items SELECTED or ALL items and populates array apUnkObjects with pointers to those objects.
Explicit interface implemetationPrivate method ISelectionContainer.SelectObjects Sets the collection of selectable objects.

Top

Remarks

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.

Thread Safety

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

See Also

Reference

Microsoft.VisualStudio.Shell Namespace

ISelectionContainer

Other Resources

Selection and Currency in the IDE