Articles → .NET → Add An Option In Error List Context Menu Visual Studio Add-In
Add An Option In Error List Context Menu Visual Studio Add-In
Create A New Project
- Go to file – ‘New project’ - ‘Visual Studio Add-in’
Click to Enlarge
- The following window appears
Click to Enlarge
- In the next window, select ‘Create an Add-in using Visual C#’ and click on ‘Next’
Click to Enlarge
- In the following window click on ‘Next’
Click to Enlarge
- In the following window, you can enter the name and description of the add-in. Once you edit the information click on ‘Next’ button.
Click to Enlarge
- In the following figure, don’t select any checkbox. Click on ‘Next’
Click to Enlarge
- In the following window, you can add ‘About’ information about the add-in. Once done click on ‘Next’
Click to Enlarge
- Finally, click on ‘Finish’ in the following window
Click to Enlarge
Add Code To Add An Option In Context Menu Of Error List
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) {
_applicationObject = (DTE2) application;
_addInInstance = (AddIn) addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup) {
object[] contextGUIDS = new object[] {};
Commands2 commands = (Commands2) _applicationObject.Commands;
Microsoft.VisualStudio.CommandBars.CommandBar errorListCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars) _applicationObject.CommandBars)["Error List"];
CommandBarControl ctrlExportErrorListToExcel = errorListCommandBar.Controls.Add(MsoControlType.msoControlButton, 1, Missing.Value, Missing.Value, Missing.Value);
ctrlExportErrorListToExcel.Caption = "Export to excel";
CommandBarButton handler = (CommandBarButton) ctrlExportErrorListToExcel;
handler.Click += new _CommandBarButtonEvents_ClickEventHandler(handler_Click);
}
}
void handler_Click(CommandBarButton Ctrl, ref bool CancelDefault) {
// Call method here
}
Output
Click to Enlarge