Adjust combo box

2090
7
06-21-2011 05:44 AM
JamesWhisenhunt
New Contributor III
Hello all,

I know this is probably a very simple question but I am stuck.  I created a combo box and placed it on a tool bar.  I would like to adjust the width of the combo box; however, I can't find the properties. 

Any help is greatly appreciated. 

Thanks,
James
0 Kudos
7 Replies
SandhyaYamarthi
New Contributor
Hello all,

I know this is probably a very simple question but I am stuck.  I created a combo box and placed it on a tool bar.  I would like to adjust the width of the combo box; however, I can't find the properties. 

Any help is greatly appreciated. 

Thanks,
James


Hi,
From your posting, I assumed that you developed an Add-In command of type Combobox and you placed it on a tool bar, but after you checked its width, you want to adjust the width.
If I'm not mistaken, you can modify the "sizeString" property of the that Command of type Combobox in the Add-In's Config.esriaddinx file.
While you were creating the combobox its default value would have set to something like this: "WWWWWWW".
So now you can adjust the width of that string by increasing numbering "W"s if you want to increase the width of the combobox or remove some of those "W"s if you want to decrease the width of the combobox.
Hope it helps!!!
0 Kudos
JamesWhisenhunt
New Contributor III
Thank you. 

I looked at the Config.esriaddinx and didn't see anything about size.  after reading your post I added   sizeString="WWWWWWWWWWWWWWWWWW" to the config and it works perfectly.

Thanks a lot!

James
0 Kudos
SandhyaYamarthi
New Contributor
Thank you. 

I looked at the Config.esriaddinx and didn't see anything about size.  after reading your post I added   sizeString="WWWWWWWWWWWWWWWWWW" to the config and it works perfectly.

Thanks a lot!

James



I'm glad its working.
Actually when an Add-In command of type Combobox is getting created, there are some properties to be set where the "Size String" is also one of those. If we move the mouse over "Size String" property it displays its tool tip as "The string to determine the width of the combo box on the tool bar".
0 Kudos
JamesWhisenhunt
New Contributor III
Thanks.......I just added a new combobox to see how the setup worked.  I overlooked those properties before. 

I actually have another question along the same lines; however, this may be better suited for a new thread.  How do I access the combobox form another component.  For example if I create a button and in it's OnClick event I  want to add  "Hello" and "World" to the combo box. 

I assume I access this through the namespace of the command but am not having any luck.

As always thanks for the help,
James
0 Kudos
SandhyaYamarthi
New Contributor
Thanks.......I just added a new combobox to see how the setup worked.  I overlooked those properties before. 

I actually have another question along the same lines; however, this may be better suited for a new thread.  How do I access the combobox form another component.  For example if I create a button and in it's OnClick event I  want to add  "Hello" and "World" to the combo box. 

I assume I access this through the namespace of the command but am not having any luck.

As always thanks for the help,
James


Hi,
Here is the code to Add Items to a combobox add-in by clicking a Command button add-in:

////Code in Combo box class:
public class combo : ESRI.ArcGIS.Desktop.AddIns.ComboBox
    {
        public static combo cb;
        public combo()
        {
            cb = this;
        }

        public void AddItem(string itemname)
        {
            int i = cb.Add(itemname);
            cb.Select(i);

        }
        protected override void OnUpdate()
        {

        }
    }



///Code in OnClick Event of the Command button class:
protected override void OnClick()
        {
           
            try
            {
                combo cb = combo.cb;
                cb.AddItem("Hello");
                cb.AddItem("World");

            }
            catch (Exception Err)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + Err.Message);
            }
           

        }

I hope it helps, if you want to clear the items before adding a group of items, you can use cb.Clear( ) in combo class and call it in button class.
0 Kudos
JamesWhisenhunt
New Contributor III
Thank you! 

I didn't think about creating an add/clear procedure.  I assumed that I would be able to access the add function of the combo box. 

This is great stuff!!!
0 Kudos
SandhyaYamarthi
New Contributor
Thank you! 

I didn't think about creating an add/clear procedure.  I assumed that I would be able to access the add function of the combo box. 

This is great stuff!!!


Yes, Combo box add-in has "Add" function that can take both item's string and tag.
I used this function in AddItem method in the Combo class and called that in the button click event.
0 Kudos