locked
Can't add a separator into CommandBar RRS feed

  • Question

  •  

    Hello!

     

    I'm making a plug-in for VS2010. I have to place some menu items under "Edit" menu- Here is my code:

     

                if (connectMode == ext_ConnectMode.ext_cm_Startup)
                {
    
                    // 1) Find menu in the menu bar
                    CommandBarPopup toolsCmdBar = null;
                    CommandBar menuBar = (application.CommandBars as CommandBars)["MenuBar"];
                    foreach (CommandBarControl cmdBarCtrl in menuBar.Controls)
                    {
                        if (cmdBarCtrl.accName.Equals(this.MenuBarName) == true)
                        {
                            toolsCmdBar = cmdBarCtrl as CommandBarPopup;
                            break;
                        }
    
                    }
    
                    // 3) Look for command in the command bar
                    Command editorCmd = null;
                    Commands2 commands = m_applicationObject.Commands as Commands2;
                    string cmdName = string.Format("{0}.{1}", m_addIn.ProgID, this.Name);
                    foreach (Command cmd in commands)
                    {
                        if (cmd.Name.Equals(cmdName) == true)
                        {
                            editorCmd = cmd;
                            break;
                        }
                    }
    
                    // 3.1) Well, let's create the command, if it was not created yet...
                    if (editorCmd == null)
                    {
                        object[] contextGUIDS = new object[] { };
                        editorCmd = commands.AddNamedCommand2(addInInst, this.Name, this.ButtonText, this.ToolTip, true, Type.Missing, contextGUIDS, (int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled), (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
                        if (this.HasShortcut)
                            editorCmd.Bindings = string.Format("Global::{0}", this.Shortcut);
    
                        // 4) Add command to the menu
                        if (editorCmd != null)
                        {
                            CommandBarControl btn = editorCmd.AddControl(toolsCmdBar.CommandBar) as CommandBarControl;
                            btn.BeginGroup = true;
                        }
                    }
                }
    
    


    so setting of the property "BeginGroup" will be ignored and there is no separator.

    How can i place separator into the menu?

     

    • Moved by Leo Liu - MSFT Friday, September 30, 2011 3:42 AM Moved for better support. (From:Visual C# General)
    Thursday, September 29, 2011 12:42 PM

Answers

All replies