Compartilhar via


IVsExpansionClient.OnItemChosen Method

Called when a code snippet name has been selected from an IntelliSense menu.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)

Syntax

'Declaration
Function OnItemChosen ( _
    pszTitle As String, _
    pszPath As String _
) As Integer
int OnItemChosen(
    string pszTitle,
    string pszPath
)
int OnItemChosen(
    [InAttribute] String^ pszTitle, 
    [InAttribute] String^ pszPath
)
abstract OnItemChosen : 
        pszTitle:string * 
        pszPath:string -> int
function OnItemChosen(
    pszTitle : String, 
    pszPath : String
) : int

Parameters

  • pszTitle
    Type: System.String

    [in] A string containing the full name of the code snippet.

  • pszPath
    Type: System.String

    [in] A string containing the full path to the snippet file.

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 textmgr2.idl:

HRESULT IVsExpansionClient::OnItemChosen(
   [in] BSTR pszTitle,
   [in] BSTR pszPath
);

This method is called when the user selects a code snippet from a list of snippets, typically presented in an IntelliSense menu. The menu is shown as a result of a call to the InvokeInsertionUI method in the IVsExpansionManager interface.

A typical implementation of the OnItemChosen method is to call the InsertNamedExpansion method on the IVsExpansion object that was cached in the IVsExpansionClient object before the InvokeInsertionUI method was called. In fact, the only time the OnItemChosen method is called is when the InvokeInsertionUI method is called, either as a result of the user selecting a menu option that triggers the call or if the user is allowed to choose from multiple code snippets that have the same name (for example, if a code snippet shortcut matches more than one code snippet, a "disambiguation user interface" is shown to allow the user to select which code snippet to actually insert).

.NET Framework Security

See Also

Reference

IVsExpansionClient Interface

Microsoft.VisualStudio.TextManager.Interop Namespace