Adding IToolbarDef to a toolbar control

277
0
08-07-2012 08:52 AM
dbrandon
New Contributor
Hey all: 

I am converting some code developed for ArcGIS 9.x to ArcGIS 10.  It deals with adding a collection of toolbars to a toolbar control that is added to a stand alone application.  The original code looks something like this:


UID uid = new UIDClass();

for (int i = 0; i < toolbarList.Count; i++)
{
        try
        {
                uid.Value = toolbarList.progid;

                AxToolbarControl toolbarCtrl = new AxToolbarControl();
                ((System.ComponentModel.ISupportInitialize)(toolbarCtrl )).BeginInit();
                toolbarCtrl .Margin = new System.Windows.Forms.Padding(4);
                Controls.Add(toolbarCtrl);
                ((System.ComponentModel.ISupportInitialize)(toolbarCtrl )).EndInit();

               toolbarCtrl.AddToolbarDef(uid, -1, true, 4, esriCommandStyles.esriCommandStyleIconOnly);

               ...
        }
        catch(Exception ex)
        {
               MessageBox.Show("Cannot add toolbar [" + toolbarList.progid.ToString() + "]");
        }
}



With 9.3 this code would work but now it is not.  I don't know if the problem is with this code or the first toolbar (I have only converted the first one) itself however, I am able to pull the toolbar into ArcMap 10 and it displays just fine.  If I take the first two commands from the toolbar in question and add them using toolbarCtrl.AddItem(item), the toolbar loads just fine.

Any ideas that might get this going again?

Thanks.
0 Kudos
0 Replies