AnsweredAssumed Answered

Adding several buttons with AddCommandItem2

Question asked by Christoph Engelhardt on Apr 18, 2017
Latest reply on Apr 19, 2017 by Christoph Engelhardt

Hi there,

I use the following code in an addin to create a command manager group and I would like to add three buttons with AddCommandItem2:

 

public void AddCommandMgr()

        {

            ICommandGroup cmdGroup;

 

            Assembly thisAssembly;

            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());

 

            cmdGroup = iCmdMgr.CreateCommandGroup(1, "Tools", " ??? ", " !!! ", 3);

 

            cmdGroup.AddCommandItem2("Function 1", 0, "Number 1", "first", 0, "function1", null, 0, (int)(swCommandItemType_e.swMenuItem |                          swCommandItemType_e.swToolbarItem));

            cmdGroup.AddCommandItem2("Function 2", -1, "Number 2", "second", 0, "function2", null, 0, (int)(swCommandItemType_e.swMenuItem |                                                            swCommandItemType_e.swToolbarItem));

            cmdGroup.AddCommandItem2("Function 3", -1, "Number 3", "third", 0, "function3", null, 0, (int)(swCommandItemType_e.swMenuItem |                          swCommandItemType_e.swToolbarItem));

 

            cmdGroup.HasToolbar = true;

            cmdGroup.HasMenu = true;

            cmdGroup.Activate();

        }

 

Unfortunately, the toolbar shows one button for function 3 (first screenshot) instead of three buttons for function 1, 2 and 3. The menu shows three times function 3 instead of function 1, 2, and 3 (second screenshot).

 

 

Am I missing something?

 

Thanks in advance for your comments!

Outcomes