ArcGIS Pro二次开发-获得字段唯一值
private List<string> getunValue(FeatureLayer aFeatureLayer, string FieldName) { QueryFilter qf = new QueryFilter() { PrefixClause = "DISTINCT", //DISTINCT does not work in this query. See workaround below. SubFields = FieldName, WhereClause = FieldName + " IS NOT NULL", PostfixClause = "ORDER BY " + FieldName }; List<string> pList = new List<string>(); QueuedTask.Run(() => { RowCursor rows = aFeatureLayer.Search(qf); int fldIndex = rows.FindField(FieldName); while (rows.MoveNext()) { string value = rows.Current.GetOriginalValue(fldIndex) as string; pList.Add(value); } MessageBox.Show("" + pList.Count); return pList; }); return null; }