How will I get particular menu click notification in C# code. RRS feed

  • Question

  • I am working on Visual Studio SDK. I am facing one problem as follows.

    When we clicked on "Edit" menu of standard visual studio, submenus (i.e. cut, copy, paste etc) appears under "Edit" menu.


    I just want to know that if we clicked on "Edit"-> "Delete", how come I know it in C#(in code) that "Edit" menu header is clicked or "delete" option is clicked by user.

    In other words, how I will get the notification in code – that particular menu/submenu is clicked.


    Thanks in advance.

    Thursday, December 5, 2013 12:11 PM


  • Onkar,

    You can subscribe to the command execution events with the following code:

    events = dte.Events;
    commandEvents = events.get_CommandEvents(null, 0);
    commandEvents.AfterExecute += OnAfterExecute;

    In your OnAfterExecute handler you can check if it is the Edit.Delete command.

    Sergey Vlasov | Vlasov Studio | Visual Studio add-ins, extensions and tools

    • Proposed as answer by Anna Cc Tuesday, December 10, 2013 8:28 AM
    • Marked as answer by Anna Cc Wednesday, December 18, 2013 9:49 AM
    Friday, December 6, 2013 9:59 AM