1

I have created the ArcMap addin, according to walkthrough: "Building custom UI elements using add-ins". Now I don't know how to get rid of annoying "feature": the label of the combo placed to the left, and the dropped down list is aligned to the left, actually under the label, not under the combo edit area, as it intuitively should be.

Can somebody shed a light on this problem ?

Example

2
  • 1
    Can you show a screen shot of this issue? What software are you using to create the Add-In? Visual Studio? Commented Apr 11, 2018 at 12:10
  • Image added. I work with Arcmap 10.5.1, ArcObjects SDK 10.5.1 and VS 2015
    – Gena
    Commented Apr 11, 2018 at 12:51

1 Answer 1

1

I submitted a support issue to Esri back in 2013--it's related to 2 known bugs: NIM065082, NIM080660.

They sent me a work-around, but to be honest, I don't think I ever implemented (I didn't have a long caption like yours).

And I don't really understand how CalculateItemSizeString would help--it isn't called. But this is the work-around Esri sent.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ArcMapAddin3
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Diagnostics;
    using System.Linq;
    using ESRI.ArcGIS.Desktop.AddIns;
    using ESRI.ArcGIS.esriSystem;   
    using ESRI.ArcGIS.Framework;



    public class Combo1 : ComboBox
    {
        private IApplication app = null;


        public Combo1()
        {

            this.app = this.Hook as IApplication;

            OnCreate();

        }



        protected override void OnUpdate()
        {
            Enabled = ArcMap.Application != null;
        }

        private Dictionary<int, string> itemMap = new Dictionary<int, string>();


        private void OnCreate()
        {

            app = this.Hook as IApplication;

            int cookie = 0;

            string valuestring = @"Lorem,ipsum,dolor,sit,amet,,consectetur,adipiscing,elit.,Eleifend,conubia,urna,tempor,quam.Consectetur,Libero,dis.Venenatis,vehicula,torquent,pretium,turpis,nec,sed,proin:,litora,eget,natoque,lacinia,diam!Aliquet,tellus,Fermentum,consequat,proin,ac,bibendum,,dignissim,nullam,vestibulum,quam,diam,risus.Sapien,gravida,magnis";


            var values = valuestring.Split(',').ToList().Distinct();

            foreach (var value in values)
            {
                cookie = this.Add(value);
                itemMap.Add(cookie, value);
            }
        }



        protected override void OnSelChange(int cookie)
        {

            string selectedValue = itemMap[cookie];

            Trace.Write(string.Format("cookie={0},value={1}", cookie, selectedValue));


        }

        public static int CalculateItemSizeString(string caption, int comboBoxSize)
        {
            int adjustment = 5;

            var i = caption.Length + comboBoxSize;

            return i - 5;



            // sizeString
        }

    }



}
1
  • Thanks. Think, I'll also shall trim the caption to one blank. "System restriction" :-) But anyway I'd like to know how to correctly avoid this problem without loss of functionality.
    – Gena
    Commented Apr 11, 2018 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.