AnsweredAssumed Answered

Set Field IsVisibe to false ArcGIS Pro SDK

Question asked by garydlester on Oct 17, 2018

I am trying to hide some fields with an add-in. The documentation says that the IsVisible property for a FieldDescriptions object can be get or set. I am coming from python so I am not sure if setting the property is quiet the same in c#.

 

Here is link to IsVisible porperty ArcGIS Pro 2.2 API Reference Guide 

Here is the code I have so far

internal class Hide : Button
    {
        protected async override void OnClick()
        {
            await HideFields();
        }
        public Task HideFields()
        {
            return QueuedTask.Run(() =>
            {
                List<string> fieldList = new List<string>() { "NORTH","EAST","HRMS","PDOP","SATELLITES","LATITUDE","LONGITUDE","PHOTO","PRODUCT_TYPE","LINE_TYPE","AFE","FILE_NAME","WELD_TYPE","WELD_LOCATION","XRAY_PERCENTAGE"};
                var mapView = MapView.Active;
                var listLayers = mapView.Map.Layers.OfType<FeatureLayer>();
                foreach(var lyr in listLayers.ToList())
                {
                   
                    var fields = lyr.GetFieldDescriptions().Where(f => fieldList.Contains(f.Name, StringComparer.OrdinalIgnoreCase));
                    foreach(var field in fields)
                    {
                        FieldDescription fieldDesc = field;
                        fieldDesc.IsVisible=false;

                   
                        //MessageBox.Show(field.Name.ToString());
                    }
                }
            });
        }
    }

Outcomes