AnsweredAssumed Answered

Combo Box Reload

Question asked by mjk5000 on Feb 9, 2018
Latest reply on Feb 12, 2018 by gkmieliauskas_cellexp

I am using an ESRI Combo Box in my toolbar.  This Combo Box is loaded with the IDs of whatever polygons are in my map.  When a user switches to another location, with a whole new set of polygons, I want my Combo Box to update itself.  The problem is that I can't seem to figure out how to run my Update/Populate logic from outside of the combobox code.  I need to be able to tell the combo box from other functions to revalidate or reinitialize itself?  I think I need to make some static reference to this function, but can't seem to be able to accomplish this?  The below code works initially, but when the user switches, i need to be able to call updateCombo from anywhere, or just tell the combo to reload.

 

        public GoToCurrent()
        {
            UpdateCombo();
        }      

        public async void UpdateCombo()
        {
            try
            {
                Enabled = false;

                Clear();
                SortedSet<string> FieldIdList = await FeatureServiceManagement.getFeatureLayerUniqueList("Current Field", "", "CurrentFieldId");

                if (!FieldIdList.IsNullOrEmpty())
                {
                    foreach (string fieldID in FieldIdList)
                    {
                        Add(new ComboBoxItem(fieldID));
                    }
                }

                Enabled = true;
            }
            catch (Exception e)
            {
                logError("UpdateCombo", e);
            }
        }

Outcomes