IVsUserContext::GetSubcontext Method (Int32, IVsUserContext^)

 

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)

int GetSubcontext(
	int i,
	[OutAttribute] IVsUserContext^% ppSubCtx
)

Parameters

i
Type: System::Int32

[in] Index position of the subcontext bag on the parent context bag. This index is zero based.

ppSubCtx
Type: Microsoft.VisualStudio.Shell.Interop::IVsUserContext^

[out, retval] Pointer to the IVsUserContext interface, representing the subcontext bag.

Return Value

Type: System::Int32

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

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.

Return to top
Show: