4

我想提出延期,我需要調用從代碼的兩個命令VS2012 Solution Explorer中的命令......調用代碼

  • SolutionExplorer.SyncWithActiveDocument
  • 的崩潰在Solution Explorer中的所有命令。

反正我找不到這些功能。

有誰知道如何做到這一點?

回答

4

您是否嘗試過通過DTE執行命令?

dte.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Activate(); 

// Sync with Active Document 
dte.ExecuteCommand("SolutionExplorer.SyncWithActiveDocument"); 

// Collapse All 
int cmdidSolutionExplorerCollapseAll = 29; 
Guid guidCMDSETID_StandardCommandSet11 = new Guid("D63DB1F0-404E-4B21-9648-CA8D99245EC3"); 
dte.Commands.Raise(guidCMDSETID_StandardCommandSet11.ToString("B"), cmdidSolutionExplorerCollapseAll, null, null); 

如果您需要識別ID的任何其他命令,你可以在VSIP日誌切換: http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

+0

謝謝!你幾乎爲我寫了我的擴展。 –

+0

不用擔心隊友,它或多或少是我自己代碼的副本+粘貼:) –