簡體   English   中英

如何在Visual Studio 2017中為.sql文件創建自定義擴展名

[英]How to create custom extension for .sql file in visual studio 2017

我是Visual Studio擴展的新手。 我需要為Visual Studio 2017創建一個新擴展名,並且此擴展名適用於.sql文件。 如果解決方案具有.sql文件,並且如果用戶右鍵單擊.sql文件,則我需要具有新的自定義選項以在寫字板中打開文件。

任何幫助或指導將不勝感激。

只需在解決方案資源管理器>打開方式中右鍵單擊文件。 然后只需對其進行配置:

在此處輸入圖片說明

Visual Studio是最好的IDE之一,即使不是最好的,也不確定為什么要使用寫字板,但這至少會使您免於擴展。


如果您確實想做到這一點,請參閱以下示例,了解如何將菜單項添加到“上下文菜單”中,它將為您提供Google關鍵字:

Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;


Command command = commands.AddNamedCommand2(_addInInstance, "AddinMultiLineWatch", "AddinMultiLineWatch", "Executes the command for AddinMultiLineWatch", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

if((command != null) && (toolsPopup != null))
{
    command.AddControl(toolsPopup.CommandBar, 1);
}

參考: https : //stackoverflow.com/a/38500621/495455

這里是一些您可以開始的資源。

我認為您想向上下文菜單( 文本編輯器Solution Explorer的菜單)添加命令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM