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());
}
}
});
}
}
Hi Gary -
Did you resolve this issue?
It looks like you had it, save but one line of code.
In fact your snippet helped me, so thank you!
Basically i think you could add "lyr.SetFieldDescriptions(fields);" to line 23.
The method is also mentioned here, so thank you, too, Uma Harano @UHarano-esristaff:
https://community.esri.com/thread/234346-how-to-change-field-visibility-and-alias
Good Luck!
+ bill