Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5962937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:10:34+00:00 2026-05-22T19:10:34+00:00

I am trying to dynamically fill the Solution right click menu with menu items

  • 0

I am trying to dynamically fill the Solution right click menu with menu items from VS Package (Extension).

I have a extension menu with name “MyMenuName” and I am adding menu items there.

Here is the code I use:

        DTE2 dte = GetService(typeof (DTE)) as DTE2;

        CommandBars cmdBars = dte.CommandBars as CommandBars;

        CommandBar owner = cmdBars["MyMenuName"];

        CommandBarControl ctl1 = owner.Controls.Add(
            MsoControlType.msoControlButton, 1, string.Empty, 1, true);
        ctl1.Caption = "caption";
        ctl1.Enabled = true;

        //register on the Click event of the
        //button menu item
        CommandBarEvents buttonMenuItemHandler = (CommandBarEvents)dte.DTE.Events.CommandBarEvents[ctl1];

        buttonMenuItemHandler.Click += buttonMenuItemHandler_Click;

Menu Item is added successfully, but it Click handler never gets executed. Any ideas?

Edit: I digged some code here: https://netrepo.svn.codeplex.com/svn/trunk/AssemblyFactoryAddin/AssemblyFactoryAddin/GUIButton.cs
And it seems that my code should be correct (assuming that their code works)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:10:35+00:00Added an answer on May 22, 2026 at 7:10 pm

    Rather than working with CommandBarControl use CommandBarButton instead. E.g.:

    var button = (CommandBarButton)owner.Controls.Add(MsoControlType.msoControlButton);
    button.Caption = "caption";
    button.Enabled = true;
    button.Click += OnButtonClick;`
    

    This will fix the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically segment each generated-label and hardcoded input pair with div tag's.
I am trying to dynamically filter out content using checkboxes and jquery. Being new
I'm trying to dynamically build a LINQ query for LINQ to Entities so that
I'm trying to dynamically get a databases Table structure using only C# code as
This is in C# So I'm trying to create an event for ProgressChanged for
I am very new to Android Development. I am trying a sample application and
I've successfully built SDL from source using bcc 5.5.1 but any SDL test application
Hey folks, I have to apologize for my inexperience here, I've been working on
I am using the __call magic within some of my mvc code to produce
So my problem may be a little bigger than that, but I'm not certain.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.