How to add a button to Visual Studio Intellisense

会有一股神秘感。 提交于 2019-12-03 06:20:43

问题


I would like to add a button to the top of the list of options returned by Visual Studio's IntelliSense. When the button is clicked, my custom code will be executed (which will, among other things, cause a popup to appear).

I call it 'button' because when the user click the item, I want a popup window to appear, as opposed to the normal IntelliSense action of completing the user's input.

Eg When we input a class name into the text editor, normally the static properties and static methods will appear in IntelliSense. But I want to add another item to the top of that list.

This item should appear at the top of the IntelliSense list, no matter what input/content caused IntelliSense to appear. The item will never change.

Is this possible, and if so, can you provide some direction as to how I should achieve this?


回答1:


1) In a C# or VB project, open a code file and put the cursor where you want to insert the code snippet.

2) Bring up the code snippet menu in one of three ways:

    Press CTRL+K, CTRL+X.

    On the Edit menu, point to IntelliSense, and then click Insert Snippet.

    Right-click the mouse and then select the Insert Snippet command on the shortcut menu.

3) Select the code snippet from the code snippet inserter and then press TAB or ENTER, or double-click the snippet.




回答2:


In the IntelliSense property page, clear text box options or check box options for IntelliSense features that you do not want:

Show completion list after a character is typed

Committed by typing the following characters

Committed by pressing the space bar

IntelliSense pre-selects most recently used members applies to IntelliSense for Most Recently Used Members

For more information, see IntelliSense, C#, Text Editor, Options Dialog Box



来源:https://stackoverflow.com/questions/15736884/how-to-add-a-button-to-visual-studio-intellisense

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!