Share via


IVsUserContext.GetSubcontext Method

Returns a specified subcontext bag from the parent context bag.

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

Syntax

'Declaration
Function GetSubcontext ( _
    i As Integer, _
    <OutAttribute> ByRef ppSubCtx As IVsUserContext _
) As Integer
int GetSubcontext(
    int i,
    out IVsUserContext ppSubCtx
)
int GetSubcontext(
    [InAttribute] int i, 
    [OutAttribute] IVsUserContext^% ppSubCtx
)
abstract GetSubcontext : 
        i:int * 
        ppSubCtx:IVsUserContext byref -> int 
function GetSubcontext(
    i : int, 
    ppSubCtx : IVsUserContext
) : int

Parameters

  • i
    Type: System.Int32
    [in] Index position of the subcontext bag on the parent context bag. This index is zero based.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From context.idl:

HRESULT IVsUserContext::GetSubcontext(
   [in] int i,
   [out, retval] IVsUserContext ** ppSubCtx
);

To add subcontext for a selection in a context provider, like a command in a tool window or a keyword in a language service, you need to create a subcontext bag. A subcontext bag is simply a context bag that the parent context bag points to and which holds context for the selection. By having the parent context bag point to the subcontext bag, the subcontext is also made available to the Help information provider.

Use the IVsUserContext.GetSubcontext method in conjunction with CountSubcontexts to iterate through the subcontext bags for the context provider.

.NET Framework Security

See Also

Reference

IVsUserContext Interface

Microsoft.VisualStudio.Shell.Interop Namespace