Unable to get combobox

01-31-2023 02:00 AM
New Contributor III

Hi, I have created a tool bar with a command button and a combobox using ArcObjects dotnet. For combobox I am implementing Basecommand, and IComboBox. Now I need to get the the combobox from tool bar. I am able to get CommandItem from toolbar but unable to cast the commandItem to Combobox. Any help or code sample in this regard will be greatly appreciated.


Tags (1)
0 Kudos
2 Replies
Occasional Contributor III

There is not enough information to tell what you are trying to do.  In your tool, you should be able to access the combo box data directly.  

string selecteddata = myComboBox.Text;    //or myComboBox.SelectedItem.ToString();

You will not be able to access the combo box outside of the tool.  Instead, when someone selects something, you will need to create an event in your tool that pushes the information to a place or property where that other program can find it. 

Good Luck



0 Kudos
Regular Contributor II


You need to get ICommand from ICommandItem and then tocast it to your control class. For example my control class is :

    public partial class myComboboxControl
        : UserControl, ICommand, IToolControl, ImyComboboxControl
       // class code here

Then to get my control I use code below:

                ICommand comm = pCommItem.Command;
                if (comm is myComboboxControl)
                    myComboboxControl myCombobox = comm as myComboboxControl;
                    // call myCombobox public method


0 Kudos