Here is my complicated solution (run from Package.Initialize()):
DTE2 dte = GetGlobalService(typeof (DTE)) as DTE2;
CommandBars commandBars = (CommandBars) dte.CommandBars;
CommandBar projectMenu = commandBars["Project"];
CommandBarControl control = null;
foreach (CommandBarControl barControl in projectMenu.Controls)
if (...) // currently added control
{
control = barControl;
}
// finding new position for the control
control.Move(projectMenu, newPosition); // move control to correct place
control.BeginGroup = false; // remove ugly separator above
I have many controls so they should not run this code simultaneously, just the last one. I hope you have better answer.