Select to view content in your preferred language

Combobox on a Toolbar

4323
11
09-14-2010 07:27 AM
BBulla
by
Regular Contributor
Hi,

I'd like to add a combox to a Toolbar I have created.  I understand how to add items to the toolbar, but I'm having difficulty understanding how to add a combobox (like the one you might see on the Edit Menu).  I'll need the combobox to have a list of items in it.

This is what I'm trying to do, but it's not working:

       
public DSM_Toolbar()
        {
            //
            // TODO: Define your toolbar here by adding items
            //

            AddItem("DSM_DocumentManager.DocumentManager");
            AddItem("DSM_Symbology.Symbology");
            AddItem("DSM_QCTool.QCTool");

            BeginGroup(); //Separator

            AddItem("DSM_CalcMetric.CalcMetric");
            AddItem("DSM_GIFAngle.GIF_Angle");
            AddItem("DSM_Attribute_Update.AttributeUpdater");
            
            //The ComboBox
            ComboBox combo = new ComboBox();
            combo.Items.Add("25");
            combo.Items.Add("50");

            AddItem(combo);  //this wont work though....how do I do this???
        }
0 Kudos
11 Replies
NeilClemmons
Honored Contributor
One more quick question.  I have some Tools that when I click them, I need to change the SelectedItem in the ComboBox from the OnClick event of the tool.  How do I access the ComboBox from the Tool??  I've set the Modifiers of the ComboBox to public, but I can't seem to get to it.


Brian, what you'll need to do is add a property or method to the command class that gives you the functionality that you need.  For instance, you might add a method called ChangeSelectedItem.  From the tool that needs to update the combobox, use IDocument.CommandBars to get your tool control as an ICommandItem reference.  Call ICommandItem.Command to get a reference to the underlying command class.  From there, you can QI to your actual class type and call your method.
0 Kudos
BBulla
by
Regular Contributor
What I did was add a

public static DiametersComboBoxCtrl m_diametersComboBoxCtrl = null;

to the class that inherits BaseCommand and IToolControl, and now I can access it from anywhere in my code.

Thanks!
0 Kudos