Condividi tramite


SelectionContainer Class

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

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

Syntax

<CLSCompliantAttribute(False)> _
Public Class SelectionContainer _
    Implements ISelectionContainer

Dim instance As SelectionContainer
[CLSCompliantAttribute(false)]
public class SelectionContainer : ISelectionContainer
[CLSCompliantAttribute(false)]
public ref class SelectionContainer : ISelectionContainer
public class SelectionContainer implements ISelectionContainer

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 by an external object calling SelectObjects(UInt32, [], UInt32), 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 methods.

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

The SelectionContainer 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.

For an illustration of the implementation and use of the SelectionContainer class, see the Managed Basic Editor sample.

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.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Shell.SelectionContainer

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

Concepts

Selection and Currency in the IDE

Reference

SelectionContainer Members

Microsoft.VisualStudio.Shell Namespace

ISelectionContainer