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




Picture showing the 'Visual Studio Add-in' template in 'New Project' window.

Click to Enlarge





Picture showing the first window of 'Visual Studio Add-in' wizard

Click to Enlarge





Picture showing the step two where programmer will select the programming language

Click to Enlarge



Picture showing step three for selecting application host

Click to Enlarge



Picture showing the step four where programmer will add the visual studio add-in name

Click to Enlarge



Picture showing step five where programmer can choose add-ins option

Click to Enlarge



Picture showing step six where programmer can select if add-ins should offer 'About' box information or not

Click to Enlarge



Picture showing summary screen of add-in wizard

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


Picture showing the output where 'Export to excel' option is displayed in context menu in error window

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Saturday, August 15, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250